Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix: lua stack overflow would happen when too many redis arguments…

… were passed into the build_query method. thanks Guo Yin for reporting this issue.
  • Loading branch information...
commit c54e33f3fab8b2ae665cc47b736d84d6d314ecc7 1 parent 0258b9e
@agentzh agentzh authored
Showing with 11 additions and 4 deletions.
  1. +4 −0 redis-parser.c
  2. +7 −4 t/sanity.t
View
4 redis-parser.c
@@ -590,6 +590,8 @@ redis_build_query(lua_State *L)
return luaL_error(L, "parameter %d is not a string, number, "
"redis.parser.null, or boolean value", i);
}
+
+ lua_pop(L, 1);
}
buf = lua_newuserdata(L, total); /* lua_newuserdata never returns NULL */
@@ -642,6 +644,8 @@ redis_build_query(lua_State *L)
/* cannot reach here */
break;
}
+
+ lua_pop(L, 1);
}
if (last - buf != (ssize_t) total) {
View
11 t/sanity.t
@@ -503,9 +503,12 @@ res == null\n}
--- lua
cjson = require('cjson')
parser = require("redis.parser")
-q = {"a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a"}
+q = {}
+for i = 1,2048 do
+ table.insert(q, "a")
+end
local query = parser.build_query(q)
-print("query == " .. cjson.encode(query))
---- out eval
-"query == \"*44\\r\\n" . ("\$1\\r\\na\\r\\n" x 44) . "\"\n"
+print(string.len(query))
+--- out
+14343
Please sign in to comment.
Something went wrong with that request. Please try again.