]> 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)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 9 May 2017 10:10:56 +0000 (12:10 +0200)
(cherry picked from commit 448990ab9bd7355f42ff8752a973aff20bdaf4e7)

ext/luawrapper/include/LuaContext.hpp

index 2d30d1d468c3ff57b18ea5d3abba0825388dae9f..91e3a3edb51da3e827cce1b3536a46af048921a6 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);
     }
 };