summaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-15 11:40:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-07-15 11:40:28 -0300
commit050e8536bbc7f9b22d66be6c13ea302e4e82d37a (patch)
tree71135dd0cdd010805b6a7a6599e648a45e714d81 /liolib.c
parent2b61360d826355e996ec4b9b3af7778af9d84ada (diff)
downloadlua-github-050e8536bbc7f9b22d66be6c13ea302e4e82d37a.tar.gz
bug: 'io.lines' does not check maximum number of options
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/liolib.c b/liolib.c
index f978a859..7dd4c1ba 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.145 2015/06/21 13:50:29 roberto Exp roberto $
+** $Id: liolib.c,v 2.146 2015/07/07 17:03:34 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -318,8 +318,15 @@ static int io_output (lua_State *L) {
static int io_readline (lua_State *L);
+/*
+** maximum number of arguments to 'f:lines'/'io.lines' (it + 3 must fit
+** in the limit for upvalues of a closure)
+*/
+#define MAXARGLINE 250
+
static void aux_lines (lua_State *L, int toclose) {
int n = lua_gettop(L) - 1; /* number of arguments to read */
+ luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments");
lua_pushinteger(L, n); /* number of arguments to read */
lua_pushboolean(L, toclose); /* close/not close file when finished */
lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */