mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Better string pack formats
This commit is contained in:
@@ -123,13 +123,12 @@ AJP = {
|
|||||||
__tostring = function(self)
|
__tostring = function(self)
|
||||||
|
|
||||||
-- encodes a string, prefixing it with a 2-byte length
|
-- encodes a string, prefixing it with a 2-byte length
|
||||||
-- and suffixing it with a zero. P-encoding can't be used
|
-- and suffixing it with a zero.
|
||||||
-- as the zero terminator should not be counted in the length
|
|
||||||
local function encstr(str)
|
local function encstr(str)
|
||||||
if ( not(str) or #str == 0 ) then
|
if ( not(str) or #str == 0 ) then
|
||||||
return "\xFF\xFF"
|
return "\xFF\xFF"
|
||||||
end
|
end
|
||||||
return string.pack(">I2z", #str, str)
|
return string.pack(">s2x", str)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- count the number of headers
|
-- count the number of headers
|
||||||
@@ -163,7 +162,7 @@ AJP = {
|
|||||||
for k, v in pairs(self.headers) do
|
for k, v in pairs(self.headers) do
|
||||||
local header = AJP.ForwardRequest.Header[k:lower()] or k
|
local header = AJP.ForwardRequest.Header[k:lower()] or k
|
||||||
if ( "string" == type(header) ) then
|
if ( "string" == type(header) ) then
|
||||||
data[#data+1] = string.pack(">I2z", #header, header)
|
data[#data+1] = string.pack(">s2x", header)
|
||||||
else
|
else
|
||||||
data[#data+1] = string.pack(">I2", header)
|
data[#data+1] = string.pack(">I2", header)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user