From: Peter van Dijk Date: Tue, 16 Jan 2024 14:14:28 +0000 (+0100) Subject: tidy: avoid pointer math X-Git-Tag: dnsdist-1.9.0-rc1~26^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=061c3e9f65955833e4cd110a488520a1e99a3ed3;p=thirdparty%2Fpdns.git tidy: avoid pointer math --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 388cf01205..d844b19569 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -766,8 +766,12 @@ static void setupLuaRecords(LuaContext& lua) } ret.resize(ret.size() - 1); // remove trailing dot after last octet return ret; - } else if(input.length() >= 8 && sscanf(input.c_str()+(input.length()-8), "%02x%02x%02x%02x", &x1, &x2, &x3, &x4)==4) { - return std::to_string(x1)+"."+std::to_string(x2)+"."+std::to_string(x3)+"."+std::to_string(x4); + } + if(input.length() >= 8) { + auto last8 = input.substr(input.length()-8); + if(sscanf(last8.c_str(), "%02x%02x%02x%02x", &x1, &x2, &x3, &x4)==4) { + return std::to_string(x1)+"."+std::to_string(x2)+"."+std::to_string(x3)+"."+std::to_string(x4); + } } } return allZerosIP;