From 9adda8c0f35fe9be96527455654b8b3ed594c04d Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 6 Jun 2023 15:10:48 +0000 Subject: [PATCH] Fix DNS TXT record parsing --- CHANGELOG | 3 +++ nselib/dns.lua | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d3012a95a..ee9ab9235 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #Nmap Changelog ($Id$); -*-text-*- +o [NSE] Fixed DNS TXT record parsing which caused asn-query to fail in Nmap + 7.80 and later. [David Fifield, Mike Pattrick] + Nmap 7.94 [2023-05-19] o Zenmap and Ndiff now use Python 3! Thanks to the many contributors who made diff --git a/nselib/dns.lua b/nselib/dns.lua index 184ccfe72..7fb8a76a8 100644 --- a/nselib/dns.lua +++ b/nselib/dns.lua @@ -1160,9 +1160,8 @@ decoder[types.PTR] = decDomain decoder[types.TXT] = function (entry, data, pos) - local len = entry.data:len() - local np = pos - #entry.data - local txt_len + local len = #entry.data + local np = pos - len local txt if len > 0 then @@ -1170,7 +1169,7 @@ function (entry, data, pos) entry.TXT.text = {} end - while np < len do + while np < pos do txt, np = string.unpack("s1", data, np) table.insert( entry.TXT.text, txt ) end