1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 17:09:02 +00:00

Move length checks to before string.unpack to avoid throwing errors

This commit is contained in:
dmiller
2018-09-05 19:01:51 +00:00
parent ab28140b85
commit 16504696a5
3 changed files with 28 additions and 59 deletions

View File

@@ -179,10 +179,10 @@ end
local function decodeSeq(encStr, len, pos)
local seq = {}
local sPos = 1
local sStr, newpos = string.unpack("c" .. len, encStr, pos)
if(sStr==nil) then
return seq, newpos
if #encStr - pos + 1 < len then
return seq, nil
end
local sStr, newpos = string.unpack("c" .. len, encStr, pos)
while (sPos < len) do
local newSeq
newSeq, sPos = decode(sStr, sPos)