mirror of
https://github.com/nmap/nmap.git
synced 2025-12-26 17:39: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:
@@ -68,15 +68,19 @@ Packet = {
|
||||
end,
|
||||
|
||||
__tostring = function(self)
|
||||
local len = (self.code ~= 0xF0 and #self.data + 1 or 2)
|
||||
local data = bin.pack("CC",
|
||||
len,
|
||||
self.code or 0
|
||||
)
|
||||
|
||||
if ( self.code == 0xF0 ) then
|
||||
data = data .. "\x80" -- EOT
|
||||
local len, eot
|
||||
if self.code == 0xF0 then
|
||||
eot = "\x80"
|
||||
len = 2
|
||||
else
|
||||
eot = ""
|
||||
len = #self.data + 1
|
||||
end
|
||||
local data = bin.pack("CCA",
|
||||
len,
|
||||
self.code or 0,
|
||||
eot
|
||||
)
|
||||
|
||||
return data .. self.data
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user