mirror of
https://github.com/nmap/nmap.git
synced 2025-12-16 04:39:03 +00:00
Patch to libraries that were inappropriately using globals.
Often two (or more) scripts using the same library would overwrite the globals each was using. This would result in (at best) an error or (at worst) a deadlock. The patch changes the global accesses to local.
This commit is contained in:
@@ -65,7 +65,7 @@ function print_hex(str)
|
||||
|
||||
-- Loop through the string, printing the hex
|
||||
for char=1, 16, 1 do
|
||||
ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
io.write(string.format("%02x ", ch))
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ function print_hex(str)
|
||||
|
||||
-- Loop through the string again, this time the ascii
|
||||
for char=1, 16, 1 do
|
||||
ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
if ch < 0x20 or ch > 0x7f then
|
||||
ch = string.byte(".", 1)
|
||||
end
|
||||
@@ -84,18 +84,18 @@ function print_hex(str)
|
||||
end
|
||||
|
||||
-- Prints out the final, partial line
|
||||
line = math.floor((string.len(str)/16)) + 1
|
||||
local line = math.floor((string.len(str)/16)) + 1
|
||||
io.write(string.format("%08x ", (line - 1) * 16))
|
||||
|
||||
for char=1, string.len(str) % 16, 1 do
|
||||
ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
io.write(string.format("%02x ", ch))
|
||||
end
|
||||
io.write(string.rep(" ", 16 - (string.len(str) % 16)));
|
||||
io.write(" ")
|
||||
|
||||
for char=1, string.len(str) % 16, 1 do
|
||||
ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
local ch = string.byte(str, ((line - 1) * 16) + char)
|
||||
if ch < 0x20 or ch > 0x7f then
|
||||
ch = string.byte(".", 1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user