]> granicus.if.org Git - pdns/commitdiff
LuaWrapper: Allow embedded NULs in strings received from Lua
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 10 Mar 2017 09:48:46 +0000 (10:48 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 14 Mar 2017 11:27:24 +0000 (12:27 +0100)
ext/luawrapper/include/LuaContext.hpp

index 827e1857715b8c94a4f600eb92216f4bb5f397b2..9cf72ca2d7850fe43876720d974f1adc730f4bd0 100644 (file)
@@ -2486,10 +2486,11 @@ struct LuaContext::Reader<std::string>
     static auto read(lua_State* state, int index)
         -> boost::optional<std::string>
     {
-        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);
     }
 };