1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 03:19:02 +00:00

Use correct default buffer position. Closes #2084

This commit is contained in:
nnposter
2020-07-17 20:46:52 +00:00
parent bdc676238f
commit 9635eabb9f
2 changed files with 7 additions and 13 deletions

View File

@@ -294,14 +294,11 @@ Comm = {
parse = function(self, buf, pos)
assert(type(buf) == "string")
if not pos then
pos = 0
end
pos = pos or 1
assert(type(pos) == "number")
assert(pos < #buf)
-- Parse the type and flags of the control packet's fixed header.
if #buf - pos + 1 < 1 then
if pos > #buf then
return false, "Failed to parse control packet."
end
local type_and_flags, pos = string.unpack("B", buf, pos)
@@ -836,11 +833,8 @@ MQTT.length_parse = function(buf, pos)
return false, "Cannot parse an empty string."
end
if not pos or pos == 0 then
pos = 1
end
pos = pos or 1
assert(type(pos) == "number")
assert(pos <= #buf)
local multiplier = 1
local offset = 0
@@ -904,11 +898,8 @@ MQTT.utf8_parse = function(buf, pos)
return false, "Cannot parse a string of less than two bytes."
end
if not pos or pos == 0 then
pos = 1
end
pos = pos or 1
assert(type(pos) == "number")
assert(pos <= #buf)
local buf_length = buf:len()
if pos > buf_length - 1 then