From 57a17415b74dc808ebd29f45236bb96073239a47 Mon Sep 17 00:00:00 2001 From: nnposter Date: Sat, 18 Aug 2018 01:00:16 +0000 Subject: [PATCH] more efficient match, avoiding strings --- scripts/asn-query.nse | 2 +- scripts/whois-ip.nse | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/asn-query.nse b/scripts/asn-query.nse index db6fd6d8c..fb4392f16 100644 --- a/scripts/asn-query.nse +++ b/scripts/asn-query.nse @@ -370,7 +370,7 @@ function get_prefix_length( range ) last = ipOps.ip_to_bin(last) for pos = 1, #first do - if first:sub(pos, pos) ~= last:sub(pos, pos) then + if first:byte(pos) ~= last:byte(pos) then return pos - 1 end end diff --git a/scripts/whois-ip.nse b/scripts/whois-ip.nse index edf12bc83..8e236e371 100644 --- a/scripts/whois-ip.nse +++ b/scripts/whois-ip.nse @@ -438,7 +438,7 @@ function get_prefix_length( range ) last = ipOps.ip_to_bin(last) for pos = 1, #first do - if first:sub(pos, pos) ~= last:sub(pos, pos) then + if first:byte(pos) ~= last:byte(pos) then return pos - 1 end end