webrick/httpservlet/*handler: use File.open
This makes future code audits easier. None of these changes fix realistic remote code execution vulnerabilities because we stat(2) before attempting Kernel#open. * lib/webrick/httpservlet/erbhandler.rb (do_GET): use File.open * lib/webrick/httpservlet/filehandler.rb (do_GET): use File.open (make_partial_content): ditto [Misc #14216] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1989371d10
commit
1ad355bd53
@ -53,7 +53,7 @@ module WEBrick
|
|||||||
raise HTTPStatus::Forbidden, "ERBHandler cannot work."
|
raise HTTPStatus::Forbidden, "ERBHandler cannot work."
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
data = open(@script_filename){|io| io.read }
|
data = File.open(@script_filename, &:read)
|
||||||
res.body = evaluate(ERB.new(data), req, res)
|
res.body = evaluate(ERB.new(data), req, res)
|
||||||
res['content-type'] ||=
|
res['content-type'] ||=
|
||||||
HTTPUtils::mime_type(@script_filename, @config[:MimeTypes])
|
HTTPUtils::mime_type(@script_filename, @config[:MimeTypes])
|
||||||
|
@ -57,7 +57,7 @@ module WEBrick
|
|||||||
res['content-type'] = mtype
|
res['content-type'] = mtype
|
||||||
res['content-length'] = st.size
|
res['content-length'] = st.size
|
||||||
res['last-modified'] = mtime.httpdate
|
res['last-modified'] = mtime.httpdate
|
||||||
res.body = open(@local_path, "rb")
|
res.body = File.open(@local_path, "rb")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ module WEBrick
|
|||||||
raise HTTPStatus::BadRequest,
|
raise HTTPStatus::BadRequest,
|
||||||
"Unrecognized range-spec: \"#{req['range']}\""
|
"Unrecognized range-spec: \"#{req['range']}\""
|
||||||
end
|
end
|
||||||
open(filename, "rb"){|io|
|
File.open(filename, "rb"){|io|
|
||||||
if ranges.size > 1
|
if ranges.size > 1
|
||||||
time = Time.now
|
time = Time.now
|
||||||
boundary = "#{time.sec}_#{time.usec}_#{Process::pid}"
|
boundary = "#{time.sec}_#{time.usec}_#{Process::pid}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user