mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Check for valid base64 before decoding (#9904)
This commit is contained in:
@@ -318,9 +318,13 @@ int ModApiUtil::l_decode_base64(lua_State *L)
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
size_t size;
|
||||
const char *data = luaL_checklstring(L, 1, &size);
|
||||
const char *d = luaL_checklstring(L, 1, &size);
|
||||
const std::string data = std::string(d, size);
|
||||
|
||||
std::string out = base64_decode(std::string(data, size));
|
||||
if (!base64_is_valid(data))
|
||||
return 0;
|
||||
|
||||
std::string out = base64_decode(data);
|
||||
|
||||
lua_pushlstring(L, out.data(), out.size());
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user