From 4021c0bb6810662eeab190f4d06c005155bfcde4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 6 Sep 2025 17:02:02 +0100 Subject: [PATCH] Fix looking up TXT records using the dns module. --- modules/dns.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/dns.cpp b/modules/dns.cpp index b55e32da4..175575225 100644 --- a/modules/dns.cpp +++ b/modules/dns.cpp @@ -197,8 +197,12 @@ class Packet final if (pos + rdlength > input_size) throw SocketException("Unable to unpack TXT resource record"); - record.rdata = std::string(reinterpret_cast(input + pos), rdlength); - pos += rdlength; + auto txtlength = input[pos++]; + if (pos + txtlength > input_size) + throw SocketException("Unable to unpack TXT resource record"); + + record.rdata = Anope::string(reinterpret_cast(input + pos), txtlength); + pos += rdlength - 1; break; } case DNS::QUERY_SRV: