fix(base64): properly handle embedded NULLs when decoding (#28349)

This commit is contained in:
Gregory Anders
2024-04-15 11:06:54 -05:00
committed by GitHub
parent 57adf8c6e0
commit 533e01a75b
3 changed files with 15 additions and 5 deletions

View File

@@ -45,12 +45,13 @@ static int nlua_base64_decode(lua_State *L)
size_t src_len = 0;
const char *src = lua_tolstring(L, 1, &src_len);
const char *ret = base64_decode(src, src_len);
size_t out_len = 0;
const char *ret = base64_decode(src, src_len, &out_len);
if (ret == NULL) {
return luaL_error(L, "Invalid input");
}
lua_pushstring(L, ret);
lua_pushlstring(L, ret, out_len);
xfree((void *)ret);
return 1;