1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-27 18:09:01 +00:00

Strip trailing whitespace when parsing torrent files. Fixes #1211

This commit is contained in:
dmiller
2018-05-14 18:19:10 +00:00
parent 3b8b6516a7
commit 0dbf3c9b16

View File

@@ -154,8 +154,7 @@ bdecode = function(buf)
cur.ref.type="list"
cur.ref.start = pos
while true do
if pos == len or (len-pos)==-1 then break end
while pos <= len do
if cur.type == "list" then
-- next element is a string
@@ -205,6 +204,10 @@ bdecode = function(buf)
cur = stack[#stack]
if not cur then return nil, "Problem with list closure:", pos end
pos = pos+1
-- trailing whitespace
elseif string.match(buf, "%s*$", pos) then
pos = len+1
else
return nil, "Unknown type found.", pos
end