From 688f8b6f7664d85f028c94ef8023cd35d8b895fd Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 5 Feb 2020 04:30:56 +0000 Subject: [PATCH] Better string pack formats --- nselib/ajp.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nselib/ajp.lua b/nselib/ajp.lua index ab1938296..b6296d063 100644 --- a/nselib/ajp.lua +++ b/nselib/ajp.lua @@ -123,13 +123,12 @@ AJP = { __tostring = function(self) -- encodes a string, prefixing it with a 2-byte length - -- and suffixing it with a zero. P-encoding can't be used - -- as the zero terminator should not be counted in the length + -- and suffixing it with a zero. local function encstr(str) if ( not(str) or #str == 0 ) then return "\xFF\xFF" end - return string.pack(">I2z", #str, str) + return string.pack(">s2x", str) end -- count the number of headers @@ -163,7 +162,7 @@ AJP = { for k, v in pairs(self.headers) do local header = AJP.ForwardRequest.Header[k:lower()] or k if ( "string" == type(header) ) then - data[#data+1] = string.pack(">I2z", #header, header) + data[#data+1] = string.pack(">s2x", header) else data[#data+1] = string.pack(">I2", header) end