mirror of
https://github.com/fluencelabs/redis
synced 2025-06-14 17:51:21 +00:00
Scripting: Fix regression from #1118
The new check-for-number behavior of Lua arguments broke users who use large strings of just integers. The Lua number check would convert the string to a number, but that breaks user data because Lua numbers have limited precision compared to an arbitrarily precise number wrapped in a string. Regression fixed and new test added. Fixes #1118 again.
This commit is contained in:
@ -200,6 +200,11 @@ void luaSortArray(lua_State *lua) {
|
||||
lua_pop(lua,1); /* Stack: array (sorted) */
|
||||
}
|
||||
|
||||
int luaReallyIsString(lua_State *L, int index) {
|
||||
int t = lua_type(L, index);
|
||||
return t == LUA_TSTRING;
|
||||
}
|
||||
|
||||
#define LUA_CMD_OBJCACHE_SIZE 32
|
||||
#define LUA_CMD_OBJCACHE_MAX_LEN 64
|
||||
int luaRedisGenericCommand(lua_State *lua, int raise_error) {
|
||||
@ -234,7 +239,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
|
||||
size_t obj_len;
|
||||
char dbuf[64];
|
||||
|
||||
if (lua_isnumber(lua,j+1)) {
|
||||
if (!luaReallyIsString(lua, j+1) && lua_isnumber(lua, j+1)) {
|
||||
/* We can't use lua_tolstring() for number -> string conversion
|
||||
* since Lua uses a format specifier that loses precision. */
|
||||
lua_Number num = lua_tonumber(lua,j+1);
|
||||
|
Reference in New Issue
Block a user