Skip to content

Commit ee45cfc

Browse files
committed
Merge branch 'master-2.3' into dist/2.3/xenial
2 parents 6429722 + a289bb6 commit ee45cfc

File tree

17 files changed

+579
-31
lines changed

17 files changed

+579
-31
lines changed

ChangeLog

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
1+
Thu Dec 14 23:53:41 2017 NAKAMURA Usaku <[email protected]>
2+
3+
* test/net/ftp/test_ftp.rb (process_port_or_eprt): merge a part of
4+
r56973 to pass the test introduced at previous commit.
5+
6+
Thu Dec 14 22:55:05 2017 Shugo Maeda <[email protected]>
7+
8+
Fix a command injection vulnerability in Net::FTP.
9+
10+
Thu Dec 14 22:35:19 2017 Eric Wong <[email protected]>
11+
12+
webrick: compile RE correctly for beginning and end match
13+
14+
Using ^ and $ in regexps means we can accidentally get fooled
15+
by "%0a" in HTTP request paths being decoded to newline
16+
characters. Use \A and \z to match beginning and end-of-string
17+
respectively, instead.
18+
19+
Thanks to mame and hsbt for reporting.
20+
21+
* lib/webrick/httpserver.rb (MountTable#compile):
22+
use \A and \z instead of ^ and $
23+
* lib/webrick/httpserver.rb (MountTable#normalize): use \z instead of $
24+
* test/webrick/test_httpserver.rb (test_cntrl_in_path): new test
25+
26+
Thu Dec 14 22:29:04 2017 Eric Wong <[email protected]>
27+
28+
webrick: do not hang acceptor on slow TLS connections
29+
30+
OpenSSL::SSL::SSLSocket#accept may block indefinitely on clients
31+
which negotiate the TCP connection, but fail (or are slow) to
32+
negotiate the subsequent TLS handshake. This prevents the
33+
multi-threaded WEBrick server from accepting other connections.
34+
35+
Since the TLS handshake (via OpenSSL::SSL::SSLSocket#accept)
36+
consists of normal read/write traffic over TCP, handle it in the
37+
per-client thread, instead.
38+
39+
Furthermore, using non-blocking accept() is useful for non-TLS
40+
sockets anyways because spurious wakeups are possible from
41+
select(2).
42+
43+
* lib/webrick/server.rb (accept_client): use TCPServer#accept_nonblock
44+
and remove OpenSSL::SSL::SSLSocket#accept call
45+
* lib/webrick/server.rb (start_thread): call OpenSSL::SSL::SSLSocket#acc
46+
ept
47+
* test/webrick/test_ssl_server.rb (test_slow_connect): new test
48+
[ruby-core:83221] [Bug #14005]
49+
50+
webrick: fix up r60172
51+
52+
By making the socket non-blocking in r60172, TLS/SSL negotiation
53+
via the SSL_accept function must handle non-blocking sockets
54+
properly and retry on SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE.
55+
OpenSSL::SSL::SSLSocket#accept cannot do that properly with a
56+
non-blocking socket, so it must use non-blocking logic of
57+
OpenSSL::SSL::SSLSocket#accept_nonblock.
58+
59+
Thanks to MSP-Greg (Greg L) for finding this.
60+
61+
* lib/webrick/server.rb (start_thread): use SSL_accept properly
62+
with non-blocking socket.
63+
[Bug #14013] [Bug #14005]
64+
65+
webrick: fix up r60172 and revert r60189
66+
67+
Thanks to MSP-Greg (Greg L) for helping with this.
68+
69+
* lib/webrick/server.rb (start_thread): ignore ECONNRESET, ECONNABORTED,
70+
EPROTO, and EINVAL on TLS negotiation errors the same way they
71+
were ignored before r60172 in the accept_client method of the
72+
main acceptor thread.
73+
[Bug #14013] [Bug #14005]
74+
75+
webrick: fix up r60172 and r60208
76+
77+
Thanks to MSP-Greg (Greg L) for helping with this.
78+
79+
* lib/webrick/server.rb (start_thread): fix non-local return
80+
introduced in r60208
81+
82+
webrick: fix up r60172 and r60210
83+
84+
Thanks to MSP-Greg (Greg L) for helping with this.
85+
86+
* lib/webrick/server.rb (start_thread): properly fix non-local return
87+
introduced in r60208 and r60210
88+
89+
Thu Nov 30 23:37:08 2017 Nobuyoshi Nakada <[email protected]>
90+
91+
parse.y: fix line in rescue
92+
93+
* parse.y (set_line_body, primary): fix line number of bodystmt as the
94+
beginning of the block. [Bug #13181]
95+
96+
Thu Nov 30 23:29:00 2017 SHIBATA Hiroshi <[email protected]>
97+
98+
Merge rubygems-2.6.14 changes.
99+
100+
It fixed http://blog.rubygems.org/2017/10/09/unsafe-object-deserialization-vulnerability.html
101+
102+
Fri Sep 15 05:40:40 2017 URABE Shyouhei <[email protected]>
103+
104+
fix --with-gmp (broken by r57490)
105+
106+
Looking at the generated shell script (also the autoconf manual), it
107+
seems AC_SEARCH_LIBS() m4 macro does not define HAVE_LIBsomething C
108+
preprocessor macros, unlike AC_CHECK_LIB() which does define them.
109+
This previous change effectively killed building with GMP because
110+
building that mode depends on existence of HAVE_LIBGMP. [Bug #13402]
111+
1112
Thu Sep 14 20:25:55 2017 Yusuke Endoh <[email protected]>
2113

3114
lib/webrick/log.rb: sanitize any type of logs

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ruby2.3 (2.3.6-0nkmi1) unstable; urgency=medium
2+
3+
* new upstream version
4+
5+
-- Sorah Fukumori <[email protected]> Thu, 14 Dec 2017 18:18:53 +0000
6+
17
ruby2.3 (2.3.5-0nkmi1~xenial) xenial; urgency=medium
28

39
* new upstream version

lib/net/ftp.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ def getbinaryfile(remotefile, localfile = File.basename(remotefile),
622622
if localfile
623623
if @resume
624624
rest_offset = File.size?(localfile)
625-
f = open(localfile, "a")
625+
f = File.open(localfile, "a")
626626
else
627627
rest_offset = nil
628-
f = open(localfile, "w")
628+
f = File.open(localfile, "w")
629629
end
630630
elsif !block_given?
631631
result = String.new
@@ -655,7 +655,7 @@ def gettextfile(remotefile, localfile = File.basename(remotefile),
655655
f = nil
656656
result = nil
657657
if localfile
658-
f = open(localfile, "w")
658+
f = File.open(localfile, "w")
659659
elsif !block_given?
660660
result = String.new
661661
end
@@ -701,7 +701,7 @@ def putbinaryfile(localfile, remotefile = File.basename(localfile),
701701
else
702702
rest_offset = nil
703703
end
704-
f = open(localfile)
704+
f = File.open(localfile)
705705
begin
706706
f.binmode
707707
if rest_offset
@@ -720,7 +720,7 @@ def putbinaryfile(localfile, remotefile = File.basename(localfile),
720720
# passing in the transmitted data one line at a time.
721721
#
722722
def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
723-
f = open(localfile)
723+
f = File.open(localfile)
724724
begin
725725
storlines("STOR #{remotefile}", f, &block)
726726
ensure

lib/rubygems.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require 'thread'
1111

1212
module Gem
13-
VERSION = '2.5.2.1'
13+
VERSION = '2.5.2.2'
1414
end
1515

1616
# Must be first since it unloads the prelude from 1.9.2
@@ -602,7 +602,7 @@ def self.load_yaml
602602

603603
unless test_syck
604604
begin
605-
gem 'psych', '>= 1.2.1'
605+
gem 'psych', '>= 2.0.0'
606606
rescue Gem::LoadError
607607
# It's OK if the user does not have the psych gem installed. We will
608608
# attempt to require the stdlib version
@@ -626,6 +626,7 @@ def self.load_yaml
626626
end
627627

628628
require 'yaml'
629+
require 'rubygems/safe_yaml'
629630

630631
# If we're supposed to be using syck, then we may have to force
631632
# activate it via the YAML::ENGINE API.

lib/rubygems/config_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def load_file(filename)
332332
return {} unless filename and File.exist? filename
333333

334334
begin
335-
content = YAML.load(File.read(filename))
335+
content = Gem::SafeYAML.load(File.read(filename))
336336
unless content.kind_of? Hash
337337
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
338338
return {}

lib/rubygems/package.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def read_checksums gem
466466

467467
@checksums = gem.seek 'checksums.yaml.gz' do |entry|
468468
Zlib::GzipReader.wrap entry do |gz_io|
469-
YAML.load gz_io.read
469+
Gem::SafeYAML.safe_load gz_io.read
470470
end
471471
end
472472
end

lib/rubygems/package/old.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def file_list io # :nodoc:
101101
header << line
102102
end
103103

104-
YAML.load header
104+
Gem::SafeYAML.safe_load header
105105
end
106106

107107
##

lib/rubygems/safe_yaml.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module Gem
2+
3+
###
4+
# This module is used for safely loading YAML specs from a gem. The
5+
# `safe_load` method defined on this module is specifically designed for
6+
# loading Gem specifications. For loading other YAML safely, please see
7+
# Psych.safe_load
8+
9+
module SafeYAML
10+
WHITELISTED_CLASSES = %w(
11+
Symbol
12+
Time
13+
Date
14+
Gem::Dependency
15+
Gem::Platform
16+
Gem::Requirement
17+
Gem::Specification
18+
Gem::Version
19+
Gem::Version::Requirement
20+
YAML::Syck::DefaultKey
21+
Syck::DefaultKey
22+
)
23+
24+
WHITELISTED_SYMBOLS = %w(
25+
development
26+
runtime
27+
)
28+
29+
if ::YAML.respond_to? :safe_load
30+
def self.safe_load input
31+
::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true)
32+
end
33+
34+
def self.load input
35+
::YAML.safe_load(input, [::Symbol])
36+
end
37+
else
38+
warn "YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0)."
39+
def self.safe_load input, *args
40+
::YAML.load input
41+
end
42+
43+
def self.load input
44+
::YAML.load input
45+
end
46+
end
47+
end
48+
end

lib/rubygems/specification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ def self.from_yaml(input)
11011101
Gem.load_yaml
11021102

11031103
input = normalize_yaml_input input
1104-
spec = YAML.load input
1104+
spec = Gem::SafeYAML.safe_load input
11051105

11061106
if spec && spec.class == FalseClass then
11071107
raise Gem::EndOfYAMLException

lib/webrick/httpserver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ def compile
267267
k.sort!
268268
k.reverse!
269269
k.collect!{|path| Regexp.escape(path) }
270-
@scanner = Regexp.new("^(" + k.join("|") +")(?=/|$)")
270+
@scanner = Regexp.new("\\A(" + k.join("|") +")(?=/|\\z)")
271271
end
272272

273273
def normalize(dir)
274274
ret = dir ? dir.dup : ""
275-
ret.sub!(%r|/+$|, "")
275+
ret.sub!(%r|/+\z|, "")
276276
ret
277277
end
278278
end

0 commit comments

Comments
 (0)