mirror of
https://github.com/nmap/nmap.git
synced 2025-12-27 01:49:03 +00:00
String concat cleanup grab-bag
Mostly just eliminating concatenation-reassignments by chaining concatenations, reordering assignments to allow better use of bin.pack, and using tables to store intermediate results before concatenating them. Used strbuf as a quick fix in dhcp.lua. Eliminated some unused string variables in vulns.lua.
This commit is contained in:
@@ -583,9 +583,9 @@ Proto = {
|
||||
local new_name = new_name or ""
|
||||
|
||||
data = bin.pack(">CCSISI", COMMAND.FPCopyFile, pad, src_vol, src_did, dst_vol, dst_did )
|
||||
data = data .. bin.pack(">CIP", unicode_names, unicode_hint, src_path )
|
||||
data = data .. bin.pack(">CIP", unicode_names, unicode_hint, dst_path )
|
||||
data = data .. bin.pack(">CIP", unicode_names, unicode_hint, new_name )
|
||||
.. bin.pack(">CIP", unicode_names, unicode_hint, src_path )
|
||||
.. bin.pack(">CIP", unicode_names, unicode_hint, dst_path )
|
||||
.. bin.pack(">CIP", unicode_names, unicode_hint, new_name )
|
||||
|
||||
packet = self:create_fp_packet( REQUEST.Command, data_offset, data )
|
||||
self:send_fp_packet( packet )
|
||||
@@ -744,39 +744,28 @@ Proto = {
|
||||
-- not tested, but should work (next tag is
|
||||
-- tested)
|
||||
local octet = {}
|
||||
local j
|
||||
local addr
|
||||
|
||||
for j = 1, 8 do
|
||||
pos, octet[j] = bin.unpack(">S", packet.data, pos)
|
||||
local o
|
||||
pos, o = bin.unpack(">S", packet.data, pos)
|
||||
octet[j] = string.format("%04x", o)
|
||||
end
|
||||
|
||||
for j = 1, 7 do
|
||||
addr = addr .. string.format("%04x:", octet[j])
|
||||
end
|
||||
addr = addr .. string.format("%04x", octet[8])
|
||||
|
||||
table.insert(result.network_addresses, addr)
|
||||
table.insert(result.network_addresses, table.concat(octet, ':'))
|
||||
elseif tag == 0x07 then
|
||||
-- 16 byte ipv6 and two byte port
|
||||
local octet = {}
|
||||
local port
|
||||
local j
|
||||
local addr
|
||||
|
||||
for j = 1, 8 do
|
||||
pos, octet[j] = bin.unpack(">S", packet.data, pos)
|
||||
local o
|
||||
pos, o = bin.unpack(">S", packet.data, pos)
|
||||
octet[j] = string.format("%04x", o)
|
||||
end
|
||||
pos, port = bin.unpack(">S", packet.data, pos)
|
||||
|
||||
addr = "["
|
||||
|
||||
for j = 1, 7 do
|
||||
addr = addr .. string.format("%04x:", octet[j])
|
||||
end
|
||||
addr = addr .. string.format("%04x]:%d", octet[8], port)
|
||||
|
||||
table.insert(result.network_addresses, addr)
|
||||
table.insert(result.network_addresses,
|
||||
string.format("[%s]:%d", table.concat(octet, ':'), port))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user