Skip to content

Commit 0e916ac

Browse files
committed
Merge branch 'master-2.2' into dist/2.2/trusty
2 parents a2aee04 + 8a5c5ef commit 0e916ac

File tree

11 files changed

+338
-16
lines changed

11 files changed

+338
-16
lines changed

ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Fri Dec 15 00:08:26 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:52:11 2017 Shugo Maeda <[email protected]>
7+
8+
Fix a command injection vulnerability in Net::FTP.
9+
10+
Thu Dec 14 22:49:08 2017 SHIBATA Hiroshi <[email protected]>
11+
12+
Merge rubygems-2.6.14 changes.
13+
14+
It fixed http://blog.rubygems.org/2017/10/09/unsafe-object-deserialization-vulnerability.html
15+
116
Thu Sep 14 20:44:26 2017 SHIBATA Hiroshi <[email protected]>
217

318
* ext/json: bump to version 1.8.1.1. [Backport #13853]

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ruby2.2 (2.2.9-0nkmi1) unstable; urgency=medium
2+
3+
* new upstream version
4+
5+
-- Sorah Fukumori <[email protected]> Thu, 14 Dec 2017 18:36:14 +0000
6+
17
ruby2.2 (2.2.8-0nkmi1~trusty) trusty; 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
@@ -606,10 +606,10 @@ def getbinaryfile(remotefile, localfile = File.basename(remotefile),
606606
if localfile
607607
if @resume
608608
rest_offset = File.size?(localfile)
609-
f = open(localfile, "a")
609+
f = File.open(localfile, "a")
610610
else
611611
rest_offset = nil
612-
f = open(localfile, "w")
612+
f = File.open(localfile, "w")
613613
end
614614
elsif !block_given?
615615
result = ""
@@ -637,7 +637,7 @@ def getbinaryfile(remotefile, localfile = File.basename(remotefile),
637637
def gettextfile(remotefile, localfile = File.basename(remotefile)) # :yield: line
638638
result = nil
639639
if localfile
640-
f = open(localfile, "w")
640+
f = File.open(localfile, "w")
641641
elsif !block_given?
642642
result = ""
643643
end
@@ -683,7 +683,7 @@ def putbinaryfile(localfile, remotefile = File.basename(localfile),
683683
else
684684
rest_offset = nil
685685
end
686-
f = open(localfile)
686+
f = File.open(localfile)
687687
begin
688688
f.binmode
689689
if rest_offset
@@ -702,7 +702,7 @@ def putbinaryfile(localfile, remotefile = File.basename(localfile),
702702
# passing in the transmitted data one line at a time.
703703
#
704704
def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
705-
f = open(localfile)
705+
f = File.open(localfile)
706706
begin
707707
storlines("STOR " + remotefile, f, &block)
708708
ensure

lib/rubygems.rb

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

1111
module Gem
12-
VERSION = '2.4.5.3'
12+
VERSION = '2.4.5.4'
1313
end
1414

1515
# Must be first since it unloads the prelude from 1.9.2
@@ -598,7 +598,7 @@ def self.load_yaml
598598

599599
unless test_syck
600600
begin
601-
gem 'psych', '~> 1.2', '>= 1.2.1'
601+
gem 'psych', '~> 2.0.0'
602602
rescue Gem::LoadError
603603
# It's OK if the user does not have the psych gem installed. We will
604604
# attempt to require the stdlib version
@@ -622,6 +622,7 @@ def self.load_yaml
622622
end
623623

624624
require 'yaml'
625+
require 'rubygems/safe_yaml'
625626

626627
# If we're supposed to be using syck, then we may have to force
627628
# 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
@@ -330,7 +330,7 @@ def load_file(filename)
330330
return {} unless filename and File.exist? filename
331331

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

lib/rubygems/package.rb

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

453453
@checksums = gem.seek 'checksums.yaml.gz' do |entry|
454454
Zlib::GzipReader.wrap entry do |gz_io|
455-
YAML.load gz_io.read
455+
Gem::SafeYAML.safe_load gz_io.read
456456
end
457457
end
458458
end

lib/rubygems/package/old.rb

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

103-
YAML.load header
103+
Gem::SafeYAML.safe_load header
104104
end
105105

106106
##

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
@@ -985,7 +985,7 @@ def self.from_yaml(input)
985985
Gem.load_yaml
986986

987987
input = normalize_yaml_input input
988-
spec = YAML.load input
988+
spec = Gem::SafeYAML.safe_load input
989989

990990
if spec && spec.class == FalseClass then
991991
raise Gem::EndOfYAMLException

0 commit comments

Comments
 (0)