diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-20 13:37:12 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-20 13:37:12 -0300 |
| commit | b5dc2f9b0c57fef5f72152973938ff5265366dcd (patch) | |
| tree | 5dc0a4982e74c9312d83ef5041a065686a81c352 /bugs | |
| parent | 5273477cb9674e6580debfec502abd959d9fefa0 (diff) | |
| download | lua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.tar.gz lua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.tar.bz2 lua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.zip | |
bug: 'io.lines' does not check maximum number of options
Diffstat (limited to 'bugs')
| -rw-r--r-- | bugs | 35 |
1 files changed, 35 insertions, 0 deletions
| @@ -3460,6 +3460,41 @@ patch = [[ | |||
| 3460 | 3460 | ||
| 3461 | --[=[ | 3461 | --[=[ |
| 3462 | Bug{ | 3462 | Bug{ |
| 3463 | what = [['io.lines' does not check maximum number of options]], | ||
| 3464 | report = [[Patrick Donnell, 2015/07/10]], | ||
| 3465 | since = [[3.0]], | ||
| 3466 | fix = nil, | ||
| 3467 | example = [[ | ||
| 3468 | -- can segfault in some machines | ||
| 3469 | t ={}; for i = 1, 253 do t[i] = 1 end | ||
| 3470 | io.lines("someexistingfile", table.unpack(t))() | ||
| 3471 | ]], | ||
| 3472 | patch = [[ | ||
| 3473 | --- liolib.c 2015/07/07 17:03:34 2.146 | ||
| 3474 | +++ liolib.c 2015/07/15 14:40:28 2.147 | ||
| 3475 | @@ -318,8 +318,15 @@ | ||
| 3476 | static int io_readline (lua_State *L); | ||
| 3477 | |||
| 3478 | |||
| 3479 | +/* | ||
| 3480 | +** maximum number of arguments to 'f:lines'/'io.lines' (it + 3 must fit | ||
| 3481 | +** in the limit for upvalues of a closure) | ||
| 3482 | +*/ | ||
| 3483 | +#define MAXARGLINE 250 | ||
| 3484 | + | ||
| 3485 | static void aux_lines (lua_State *L, int toclose) { | ||
| 3486 | int n = lua_gettop(L) - 1; /* number of arguments to read */ | ||
| 3487 | + luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments"); | ||
| 3488 | lua_pushinteger(L, n); /* number of arguments to read */ | ||
| 3489 | lua_pushboolean(L, toclose); /* close/not close file when finished */ | ||
| 3490 | lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */ | ||
| 3491 | ]] | ||
| 3492 | } | ||
| 3493 | ]=] | ||
| 3494 | |||
| 3495 | |||
| 3496 | --[=[ | ||
| 3497 | Bug{ | ||
| 3463 | what = [[ ]], | 3498 | what = [[ ]], |
| 3464 | report = [[ ]], | 3499 | report = [[ ]], |
| 3465 | since = [[ ]], | 3500 | since = [[ ]], |
