fixed problem reading long lines

git-svn-id: file:///home/svn/framework3/trunk@7687 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Joshua Drake 2009-12-03 21:52:59 +00:00
parent 1d143a6ccf
commit d4f1314025
1 changed files with 19 additions and 5 deletions

View File

@ -129,17 +129,31 @@ module Exploit::Remote::Ftp
end
#
# This method reads a response up until the end of it as designated by FTP
# resposne continuation stuff
# This method reads an FTP response based on FTP continuation stuff
#
def recv_ftp_resp(nsock = self.sock)
found_end = FALSE
resp = ""
left = ""
while TRUE
got = nsock.get_once(-1, ftp_timeout)
return got if not got
data = nsock.get_once(-1, ftp_timeout)
return data if not data
got = left + data
left = ""
# handle the end w/o newline case
enlidx = got.rindex(0x0a)
if enlidx != (got.length-1)
if not enlidx
left << got
next
else
left << got.slice!((enlidx+1)..got.length)
end
end
# split into lines
rarr = got.split(/\r?\n/)
rarr.each do |ln|
if not found_end
@ -154,7 +168,7 @@ module Exploit::Remote::Ftp
end
end
if found_end
throw "ut oh!" if !left.empty?
throw "ut oh!" if left.length > 0
return resp
end
end