From b7df13296e906474052aa8e087598275bbeb1f32 Mon Sep 17 00:00:00 2001 From: henri Date: Thu, 22 Sep 2011 18:00:44 +0000 Subject: [PATCH] Fix a bug in dns.lua: ensure that dns.query() always return two values (status and response). Update asn-query.nse accordingly. --- nselib/dns.lua | 4 ++-- scripts/asn-query.nse | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nselib/dns.lua b/nselib/dns.lua index e3c02a8e3..51957a7ce 100644 --- a/nselib/dns.lua +++ b/nselib/dns.lua @@ -370,7 +370,7 @@ local answerFetcher = {} answerFetcher[types.TXT] = function(dec, retAll) local answers = {} if not retAll and dec.answers[1].data then - return string.sub(dec.answers[1].data, 2) + return true, string.sub(dec.answers[1].data, 2) elseif not retAll then stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") return false, "No Answers" @@ -599,7 +599,7 @@ local additionalFetcher = {} additionalFetcher[types.TXT] = function(dec, retAll) local answers = {} if not retAll and dec.add[1].data then - return string.sub(dec.add[1].data, 2) + return true, string.sub(dec.add[1].data, 2) elseif not retAll then stdnse.print_debug(1, "dns.aditionalFetcher found no records of the required type: TXT") return false, "No Answers" diff --git a/scripts/asn-query.nse b/scripts/asn-query.nse index 20e154471..62ddd7a5b 100644 --- a/scripts/asn-query.nse +++ b/scripts/asn-query.nse @@ -287,8 +287,8 @@ function asn_description( asn ) -- send query local query = ( "AS%s.asn.cymru.com" ):format( asn ) - local decoded_response, other_response = dns.query( query, options) - if type( decoded_response ) ~= "string" then + local status, decoded_response = dns.query( query, options ) + if not status then return "" end