Blame SOURCES/ruby-2.5.0-Fixed-command-Injection.patch

1fcd74
From ba0d5f7a6df6ba5545c3ce0b09e107e10d082d49 Mon Sep 17 00:00:00 2001
1fcd74
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
1fcd74
Date: Wed, 20 Dec 2017 04:18:31 +0000
1fcd74
Subject: [PATCH 1/3] Fixed command Injection
1fcd74
1fcd74
* resolv.rb (Resolv::Hosts#lazy_initialize): fixed potential
1fcd74
  command Injection in Hosts::new() by use of Kernel#open.
1fcd74
  [Fix GH-1777] [ruby-core:84347] [Bug #14205]
1fcd74
1fcd74
From: Drigg3r <drigg3r@yandex.com>
1fcd74
1fcd74
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1fcd74
---
1fcd74
 lib/resolv.rb | 2 +-
1fcd74
 1 file changed, 1 insertion(+), 1 deletion(-)
1fcd74
1fcd74
diff --git a/lib/resolv.rb b/lib/resolv.rb
1fcd74
index 1044b95e68..56183b837d 100644
1fcd74
--- a/lib/resolv.rb
1fcd74
+++ b/lib/resolv.rb
1fcd74
@@ -189,7 +189,7 @@ def lazy_initialize # :nodoc:
1fcd74
         unless @initialized
1fcd74
           @name2addr = {}
1fcd74
           @addr2name = {}
1fcd74
-          open(@filename, 'rb') {|f|
1fcd74
+          File.open(@filename, 'rb') {|f|
1fcd74
             f.each {|line|
1fcd74
               line.sub!(/#.*/, '')
1fcd74
               addr, hostname, *aliases = line.split(/\s+/)
1fcd74
-- 
1fcd74
2.15.1
1fcd74
1fcd74
1fcd74
From 0b6213635018ef73567388c1095ad1c556e1f4ee Mon Sep 17 00:00:00 2001
1fcd74
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
1fcd74
Date: Wed, 20 Dec 2017 04:25:01 +0000
1fcd74
Subject: [PATCH 2/3] Fixed command Injection
1fcd74
1fcd74
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed
1fcd74
  potential command injection by use of Kernel#open.
1fcd74
  [ruby-core:84347] [Bug #14205]
1fcd74
1fcd74
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1fcd74
---
1fcd74
 lib/resolv.rb            |  2 +-
1fcd74
 test/resolv/test_addr.rb | 11 +++++++++++
1fcd74
 test/resolv/test_dns.rb  | 10 ++++++++++
1fcd74
 3 files changed, 22 insertions(+), 1 deletion(-)
1fcd74
1fcd74
diff --git a/lib/resolv.rb b/lib/resolv.rb
1fcd74
index 56183b837d..48ee400efe 100644
1fcd74
--- a/lib/resolv.rb
1fcd74
+++ b/lib/resolv.rb
1fcd74
@@ -929,7 +929,7 @@ def Config.parse_resolv_conf(filename)
1fcd74
         nameserver = []
1fcd74
         search = nil
1fcd74
         ndots = 1
1fcd74
-        open(filename, 'rb') {|f|
1fcd74
+        File.open(filename, 'rb') {|f|
1fcd74
           f.each {|line|
1fcd74
             line.sub!(/[#;].*/, '')
1fcd74
             keyword, *args = line.split(/\s+/)
1fcd74
diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb
1fcd74
index 4a2df5bfca..78a28c9633 100644
1fcd74
--- a/test/resolv/test_addr.rb
1fcd74
+++ b/test/resolv/test_addr.rb
1fcd74
@@ -27,4 +27,15 @@ def test_invalid_byte_comment
1fcd74
       end
1fcd74
     end
1fcd74
   end
1fcd74
+
1fcd74
+  def test_hosts_by_command
1fcd74
+    Dir.mktmpdir do |dir|
1fcd74
+      Dir.chdir(dir) do
1fcd74
+        hosts = Resolv::Hosts.new("|echo error")
1fcd74
+        assert_raise(Errno::ENOENT) do
1fcd74
+          hosts.each_name("") {}
1fcd74
+        end
1fcd74
+      end
1fcd74
+    end
1fcd74
+  end
1fcd74
 end
1fcd74
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
1fcd74
index f21a094b20..8236078374 100644
1fcd74
--- a/test/resolv/test_dns.rb
1fcd74
+++ b/test/resolv/test_dns.rb
1fcd74
@@ -179,6 +179,16 @@ def test_invalid_byte_comment
1fcd74
     end
1fcd74
   end
1fcd74
 
1fcd74
+  def test_resolv_conf_by_command
1fcd74
+    Dir.mktmpdir do |dir|
1fcd74
+      Dir.chdir(dir) do
1fcd74
+        assert_raise(Errno::ENOENT) do
1fcd74
+          Resolv::DNS::Config.parse_resolv_conf("|echo foo")
1fcd74
+        end
1fcd74
+      end
1fcd74
+    end
1fcd74
+  end
1fcd74
+
1fcd74
   def test_dots_diffences
1fcd74
     name1 = Resolv::DNS::Name.create("example.org")
1fcd74
     name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg")
1fcd74
-- 
1fcd74
2.15.1
1fcd74
1fcd74
1fcd74
From dd71a5a9a459dbda9b9a4786f6a0b5bd59a81aae Mon Sep 17 00:00:00 2001
1fcd74
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
1fcd74
Date: Wed, 20 Dec 2017 16:04:41 +0000
1fcd74
Subject: [PATCH 3/3] fix test errors on Windows
1fcd74
1fcd74
	* test/resolv/test_addr.rb (test_hosts_by_command): on Windows, `|` is
1fcd74
	  invalid charactor for path and raises `Errno::EINVAL` if trying to
1fcd74
	  open.
1fcd74
1fcd74
	* test/resolv/test_dns.rb (test_resolv_conf_by_command): ditto.
1fcd74
1fcd74
	cf. [Bug #14205]
1fcd74
1fcd74
1fcd74
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1fcd74
---
1fcd74
 test/resolv/test_addr.rb | 2 +-
1fcd74
 test/resolv/test_dns.rb  | 2 +-
1fcd74
 2 files changed, 2 insertions(+), 2 deletions(-)
1fcd74
1fcd74
diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb
1fcd74
index 78a28c9633..14ec2651ab 100644
1fcd74
--- a/test/resolv/test_addr.rb
1fcd74
+++ b/test/resolv/test_addr.rb
1fcd74
@@ -32,7 +32,7 @@ def test_hosts_by_command
1fcd74
     Dir.mktmpdir do |dir|
1fcd74
       Dir.chdir(dir) do
1fcd74
         hosts = Resolv::Hosts.new("|echo error")
1fcd74
-        assert_raise(Errno::ENOENT) do
1fcd74
+        assert_raise(Errno::ENOENT, Errno::EINVAL) do
1fcd74
           hosts.each_name("") {}
1fcd74
         end
1fcd74
       end
1fcd74
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
1fcd74
index 8236078374..1b44f32807 100644
1fcd74
--- a/test/resolv/test_dns.rb
1fcd74
+++ b/test/resolv/test_dns.rb
1fcd74
@@ -182,7 +182,7 @@ def test_invalid_byte_comment
1fcd74
   def test_resolv_conf_by_command
1fcd74
     Dir.mktmpdir do |dir|
1fcd74
       Dir.chdir(dir) do
1fcd74
-        assert_raise(Errno::ENOENT) do
1fcd74
+        assert_raise(Errno::ENOENT, Errno::EINVAL) do
1fcd74
           Resolv::DNS::Config.parse_resolv_conf("|echo foo")
1fcd74
         end
1fcd74
       end
1fcd74
-- 
1fcd74
2.15.1
1fcd74