diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-17 07:03:57 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-17 07:03:57 +0000 |
commit | 1e8c6e2ba4eb4305a756f650248283ecad4f36cb (patch) | |
tree | c039ee1a23b5b8fa6de191bfdc3476578f37407a /lib/webrick/httprequest.rb | |
parent | 3f07e548fc8b1247824a008c970fcbcf10116a93 (diff) | |
download | ruby-1e8c6e2ba4eb4305a756f650248283ecad4f36cb.tar.gz |
* lib/webrick/httprequest.rb, lib/webrick/cgi.rb: Request-Line or
header fields shold be read with maximum length. [ruby-talk:231745]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httprequest.rb')
-rw-r--r-- | lib/webrick/httprequest.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb index 2dca0655d6..430054bb29 100644 --- a/lib/webrick/httprequest.rb +++ b/lib/webrick/httprequest.rb @@ -219,7 +219,10 @@ module WEBrick private def read_request_line(socket) - @request_line = read_line(socket) if socket + @request_line = read_line(socket, 1024) if socket + if @request_line.size >= 1024 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 @@ -317,10 +320,10 @@ module WEBrick @remaining_size = 0 end - def _read_data(io, method, arg) + def _read_data(io, method, *arg) begin WEBrick::Utils.timeout(@config[:RequestTimeout]){ - return io.__send__(method, arg) + return io.__send__(method, *arg) } rescue Errno::ECONNRESET return nil @@ -329,8 +332,8 @@ module WEBrick end end - def read_line(io) - _read_data(io, :gets, LF) + def read_line(io, size=4096) + _read_data(io, :gets, LF, size) end def read_data(io, size) |