1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

webrick: raise EOFError in parse when read line is nil

[Bug #15146]

From: Justin Li <git@justinli.net>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-09-24 07:48:33 +00:00
parent d54d9ba7de
commit 1aef602d5a
2 changed files with 10 additions and 1 deletions

View file

@ -445,12 +445,14 @@ module WEBrick
def read_request_line(socket)
@request_line = read_line(socket, MAX_URI_LENGTH) if socket
raise HTTPStatus::EOFError unless @request_line
@request_bytes = @request_line.bytesize
if @request_bytes >= MAX_URI_LENGTH and @request_line[-1, 1] != LF
raise HTTPStatus::RequestURITooLarge
end
@request_time = Time.now
raise HTTPStatus::EOFError unless @request_line
if /^(\S+)\s+(\S++)(?:\s+HTTP\/(\d+\.\d+))?\r?\n/mo =~ @request_line
@request_method = $1
@unparsed_uri = $2

View file

@ -422,4 +422,11 @@ GET /
req.body
}
end
def test_eof_raised_when_line_is_nil
assert_raise(WEBrick::HTTPStatus::EOFError) {
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(""))
}
end
end