aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-20 13:37:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-20 13:37:12 -0300
commitb5dc2f9b0c57fef5f72152973938ff5265366dcd (patch)
tree5dc0a4982e74c9312d83ef5041a065686a81c352
parent5273477cb9674e6580debfec502abd959d9fefa0 (diff)
downloadlua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.tar.gz
lua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.tar.bz2
lua-b5dc2f9b0c57fef5f72152973938ff5265366dcd.zip
bug: 'io.lines' does not check maximum number of options
-rw-r--r--bugs35
1 files changed, 35 insertions, 0 deletions
diff --git a/bugs b/bugs
index 81b9de95..24755610 100644
--- a/bugs
+++ b/bugs
@@ -3460,6 +3460,41 @@ patch = [[
3460 3460
3461--[=[ 3461--[=[
3462Bug{ 3462Bug{
3463what = [['io.lines' does not check maximum number of options]],
3464report = [[Patrick Donnell, 2015/07/10]],
3465since = [[3.0]],
3466fix = nil,
3467example = [[
3468-- can segfault in some machines
3469t ={}; for i = 1, 253 do t[i] = 1 end
3470io.lines("someexistingfile", table.unpack(t))()
3471]],
3472patch = [[
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--[=[
3497Bug{
3463what = [[ ]], 3498what = [[ ]],
3464report = [[ ]], 3499report = [[ ]],
3465since = [[ ]], 3500since = [[ ]],