From: Remi Gacogne Date: Mon, 20 Apr 2020 12:57:52 +0000 (+0200) Subject: auth: Prevent reading uninitialized memory in Lua's getLatLon() X-Git-Tag: dnsdist-1.5.0-rc2~14^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b17434c6fa6dbc732fee47855057f63c7cb41db3;p=thirdparty%2Fpdns.git auth: Prevent reading uninitialized memory in Lua's getLatLon() --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index ddcb3f7da0..7ef5bf6fe1 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -368,7 +368,7 @@ static bool getLatLon(const std::string& ip, string& loc) double latsec, lonsec; char lathem='X', lonhem='X'; - double lat, lon; + double lat = 0, lon = 0; if(!getLatLon(ip, lat, lon)) return false; @@ -532,7 +532,7 @@ void setupLuaRecords() LuaContext& lua = *s_LUA->getLua(); lua.writeFunction("latlon", []() { - double lat, lon; + double lat = 0, lon = 0; getLatLon(s_lua_record_ctx->bestwho.toString(), lat, lon); return std::to_string(lat)+" "+std::to_string(lon); }); @@ -559,7 +559,7 @@ void setupLuaRecords() auto labels= s_lua_record_ctx->qname.getRawLabels(); if(labels.size()<4) return std::string("unknown"); - double lat, lon; + double lat = 0, lon = 0; getLatLon(labels[3]+"."+labels[2]+"."+labels[1]+"."+labels[0], lat, lon); return std::to_string(lat)+" "+std::to_string(lon); });