summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_util.cpp
diff options
context:
space:
mode:
authorLejo1 <Lejo_1@web.de>2020-05-20 21:54:52 +0200
committerSmallJoker <mk939@ymail.com>2020-05-22 14:26:22 +0200
commite79bc40c0a5312baf4e8c3e33048d50b41b4a2ff (patch)
tree0d7f2c8cc29990a33d78f025d4bbca030a81130f /src/script/lua_api/l_util.cpp
parent7ab0c0662a95eb504665c940f92c2fde895929be (diff)
downloadminetest-e79bc40c0a5312baf4e8c3e33048d50b41b4a2ff.tar.gz
minetest-e79bc40c0a5312baf4e8c3e33048d50b41b4a2ff.tar.bz2
minetest-e79bc40c0a5312baf4e8c3e33048d50b41b4a2ff.zip
Check for valid base64 before decoding (#9904)
Diffstat (limited to 'src/script/lua_api/l_util.cpp')
-rw-r--r--src/script/lua_api/l_util.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index 28ee39fc8..cd63e20c2 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -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);
+
+ if (!base64_is_valid(data))
+ return 0;
- std::string out = base64_decode(std::string(data, size));
+ std::string out = base64_decode(data);
lua_pushlstring(L, out.data(), out.size());
return 1;