From: Peter van Dijk Date: Fri, 10 Mar 2017 09:48:46 +0000 (+0100) Subject: LuaWrapper: Allow embedded NULs in strings received from Lua X-Git-Tag: auth-4.0.5~1^2~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57ce8c364cb483825e1be4e01014ceeba5e6c095;p=thirdparty%2Fpdns.git LuaWrapper: Allow embedded NULs in strings received from Lua (cherry picked from commit 448990ab9bd7355f42ff8752a973aff20bdaf4e7) --- diff --git a/ext/luawrapper/include/LuaContext.hpp b/ext/luawrapper/include/LuaContext.hpp index e9627d689c..8a0075e991 100644 --- a/ext/luawrapper/include/LuaContext.hpp +++ b/ext/luawrapper/include/LuaContext.hpp @@ -2486,10 +2486,11 @@ struct LuaContext::Reader static auto read(lua_State* state, int index) -> boost::optional { - const auto val = lua_tostring(state, index); + size_t len; + const auto val = lua_tolstring(state, index, &len); if (val == 0) return boost::none; - return std::string(val); + return std::string(val, len); } };