Fix HORRIBLE but in b64/qp code.

Bug was caught by user moteus.
Code was checking if arguments was nil after using
luaL_Buffer code, which messes with the stack.
Simple to fix, though.
This commit is contained in:
Diego Nehab
2012-08-01 03:06:09 -03:00
parent 54ffcd483f
commit f329aae724
2 changed files with 9 additions and 1 deletions

View File

@ -263,6 +263,8 @@ static int mime_global_b64(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of the input */
luaL_buffinit(L, &buffer);
while (input < last)
@ -307,6 +309,8 @@ static int mime_global_unb64(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of the input */
luaL_buffinit(L, &buffer);
while (input < last)
@ -458,6 +462,8 @@ static int mime_global_qp(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 3);
/* process first part of input */
luaL_buffinit(L, &buffer);
while (input < last)
@ -531,6 +537,8 @@ static int mime_global_unqp(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of input */
luaL_buffinit(L, &buffer);
while (input < last)