1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Fix stdnse.tohex not adding separators. Fixes #2531

This commit is contained in:
dmiller
2022-09-30 20:03:37 +00:00
parent 2b4b822557
commit 914cd2b272

View File

@@ -314,14 +314,11 @@ function tohex( s, options )
-- format hex if we got a separator -- format hex if we got a separator
if separator then if separator then
local group = options.group or 2 local group = options.group or 2
local left = #hex local subs = 0
gsub(hex, ".", function(h) local pat = "(%x)(" .. rep("[^:]", group) .. ")%f[\0:]"
left = left - 1 repeat
if left % group == 0 and left > 0 then hex, subs = gsub(hex, pat, "%1:%2")
return h .. separator until subs == 0
end
return h
end)
end end
return hex return hex