From 4d789c20d238e6e34d3d486db37d8b34ad5f0f60 Mon Sep 17 00:00:00 2001 From: Renbo Date: Thu, 14 Dec 2023 11:09:28 +0800 Subject: [PATCH 1/3] update to ruby-2.5.9-111 Signed-off-by: Renbo --- ...-the-fact-that-lchmod-can-EOPNOTSUPP.patch | 91 ----- ...0-Moved-not-implemented-method-tests.patch | 128 ------- ..._bug_reporter_add-witout-raising-err.patch | 34 -- ....6.0-rdoc-6.0.2-check-nil-text-token.patch | 69 ++++ ...22-28739-Buffer-overrun-in-str2float.patch | 73 ++++ ...33621-HTTP-response-splitting-in-CGI.patch | 328 ++++++++++++++++++ ...023-28755-ReDos-vulnerability-in-URI.patch | 52 +++ ...23-28756-ReDoS-vulnerability-in-Time.patch | 41 +++ ruby-3.1.3-Fix-for-tzdata-2022g.patch | 70 ++++ ruby-3.2.0-git-2.38.1-fix-rubygems-test.patch | 27 ++ ruby.spec | 79 +++-- ...oosen-the-domain-regex-to-accept-dot.patch | 41 +++ 12 files changed, 756 insertions(+), 277 deletions(-) delete mode 100644 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch delete mode 100644 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch delete mode 100644 1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch create mode 100644 ruby-2.6.0-rdoc-6.0.2-check-nil-text-token.patch create mode 100644 ruby-2.6.10-Fix-CVE-2022-28739-Buffer-overrun-in-str2float.patch create mode 100644 ruby-2.7.7-Fix-CVE-2021-33621-HTTP-response-splitting-in-CGI.patch create mode 100644 ruby-2.7.8-Fix-CVE-2023-28755-ReDos-vulnerability-in-URI.patch create mode 100644 ruby-2.7.8-Fix-CVE-2023-28756-ReDoS-vulnerability-in-Time.patch create mode 100644 ruby-3.1.3-Fix-for-tzdata-2022g.patch create mode 100644 ruby-3.2.0-git-2.38.1-fix-rubygems-test.patch create mode 100644 rubygem-cgi-0.3.6-Loosen-the-domain-regex-to-accept-dot.patch diff --git a/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch b/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch deleted file mode 100644 index 42f47a9..0000000 --- a/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 29d9f866f686e81818fb9cf402c4fb479decb282 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= - -Date: Thu, 23 Jan 2020 15:33:42 +0900 -Subject: [PATCH 1/2] brace the fact that lchmod(2) can EOPNOTSUPP - -Musl libc has this function as a tiny wrapper of fchmodat(3posix). On -the other hand Linux kernel does not support changing modes of a symlink. -The operation always fails with EOPNOTSUPP. This fchmodat behaviour is -defined in POSIX. We have to take care of such exceptions. ---- - lib/fileutils.rb | 3 ++- - test/pathname/test_pathname.rb | 2 +- - test/ruby/test_notimp.rb | 19 ++++++++++++------- - 3 files changed, 15 insertions(+), 9 deletions(-) - -diff --git a/lib/fileutils.rb b/lib/fileutils.rb -index f56d7f9cb9..1a02d5435e 100644 ---- a/lib/fileutils.rb -+++ b/lib/fileutils.rb -@@ -1242,6 +1242,7 @@ def chmod(mode) - else - File.chmod mode, path() - end -+ rescue Errno::EOPNOTSUPP - end - - def chown(uid, gid) -@@ -1317,7 +1318,7 @@ def copy_metadata(path) - if st.symlink? - begin - File.lchmod mode, path -- rescue NotImplementedError -+ rescue NotImplementedError, Errno::EOPNOTSUPP - end - else - File.chmod mode, path -diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb -index 8a72b8026d..e381d3fa58 100644 ---- a/test/pathname/test_pathname.rb -+++ b/test/pathname/test_pathname.rb -@@ -823,7 +823,7 @@ def test_lchmod - old = path.lstat.mode - begin - path.lchmod(0444) -- rescue NotImplementedError -+ rescue NotImplementedError, Errno::EOPNOTSUPP - next - end - assert_equal(0444, path.lstat.mode & 0777) -diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb -index ddebb657bf..daa5a82d7b 100644 ---- a/test/ruby/test_notimp.rb -+++ b/test/ruby/test_notimp.rb -@@ -13,11 +13,11 @@ def test_respond_to_fork - - def test_respond_to_lchmod - assert_include(File.methods, :lchmod) -- if /linux/ =~ RUBY_PLATFORM -- assert_equal(false, File.respond_to?(:lchmod)) -- end -- if /freebsd/ =~ RUBY_PLATFORM -+ case RUBY_PLATFORM -+ when /freebsd/, /linux-musl/ - assert_equal(true, File.respond_to?(:lchmod)) -+ when /linux/ -+ assert_equal(false, File.respond_to?(:lchmod)) - end - end - -@@ -57,9 +57,14 @@ def test_call_lchmod - File.open(f, "w") {} - File.symlink f, g - newmode = 0444 -- File.lchmod newmode, "#{d}/g" -- snew = File.lstat(g) -- assert_equal(newmode, snew.mode & 0777) -+ begin -+ File.lchmod newmode, "#{d}/g" -+ rescue Errno::EOPNOTSUPP -+ skip $! -+ else -+ snew = File.lstat(g) -+ assert_equal(newmode, snew.mode & 0777) -+ end - } - end - end --- -2.26.2 - diff --git a/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch b/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch deleted file mode 100644 index 72d09bc..0000000 --- a/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 5400fc3c67446e2f7f35ea317c596e71f0cb1ca4 Mon Sep 17 00:00:00 2001 -From: Nobuyoshi Nakada -Date: Fri, 28 Feb 2020 21:15:37 +0900 -Subject: [PATCH 2/2] Moved not-implemented method tests [Bug #16662] - -Test not-implemented method with the dedicated methods, instead of -platform dependent features. ---- - test/-ext-/test_notimplement.rb | 7 +++ - test/ruby/test_notimp.rb | 90 --------------------------------- - 2 files changed, 7 insertions(+), 90 deletions(-) - delete mode 100644 test/ruby/test_notimp.rb - -diff --git a/test/-ext-/test_notimplement.rb b/test/-ext-/test_notimplement.rb -index 0eba7bdaf8..be8c3623cc 100644 ---- a/test/-ext-/test_notimplement.rb -+++ b/test/-ext-/test_notimplement.rb -@@ -10,6 +10,11 @@ def test_funcall_notimplement - end - - def test_respond_to -+ assert_include(Bug.methods(false), :notimplement) - assert_not_respond_to(Bug, :notimplement) - end -+ -+ def test_method_inspect_notimplement -+ assert_match(/not-implemented/, Bug.method(:notimplement).inspect) -+ end - end -diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb -deleted file mode 100644 -index daa5a82d7b..0000000000 ---- a/test/ruby/test_notimp.rb -+++ /dev/null -@@ -1,90 +0,0 @@ --# frozen_string_literal: false --require 'test/unit' --require 'timeout' --require 'tmpdir' -- --class TestNotImplement < Test::Unit::TestCase -- def test_respond_to_fork -- assert_include(Process.methods, :fork) -- if /linux/ =~ RUBY_PLATFORM -- assert_equal(true, Process.respond_to?(:fork)) -- end -- end -- -- def test_respond_to_lchmod -- assert_include(File.methods, :lchmod) -- case RUBY_PLATFORM -- when /freebsd/, /linux-musl/ -- assert_equal(true, File.respond_to?(:lchmod)) -- when /linux/ -- assert_equal(false, File.respond_to?(:lchmod)) -- end -- end -- -- def test_call_fork -- GC.start -- pid = nil -- ps = -- case RUBY_PLATFORM -- when /linux/ # assume Linux Distribution uses procps -- proc {`ps -eLf #{pid}`} -- when /freebsd/ -- proc {`ps -lH #{pid}`} -- when /darwin/ -- proc {`ps -lM #{pid}`} -- else -- proc {`ps -l #{pid}`} -- end -- assert_nothing_raised(Timeout::Error, ps) do -- Timeout.timeout(EnvUtil.apply_timeout_scale(5)) { -- pid = fork {} -- Process.wait pid -- pid = nil -- } -- end -- ensure -- if pid -- Process.kill(:KILL, pid) -- Process.wait pid -- end -- end if Process.respond_to?(:fork) -- -- def test_call_lchmod -- if File.respond_to?(:lchmod) -- Dir.mktmpdir {|d| -- f = "#{d}/f" -- g = "#{d}/g" -- File.open(f, "w") {} -- File.symlink f, g -- newmode = 0444 -- begin -- File.lchmod newmode, "#{d}/g" -- rescue Errno::EOPNOTSUPP -- skip $! -- else -- snew = File.lstat(g) -- assert_equal(newmode, snew.mode & 0777) -- end -- } -- end -- end -- -- def test_method_inspect_fork -- m = Process.method(:fork) -- if Process.respond_to?(:fork) -- assert_not_match(/not-implemented/, m.inspect) -- else -- assert_match(/not-implemented/, m.inspect) -- end -- end -- -- def test_method_inspect_lchmod -- m = File.method(:lchmod) -- if File.respond_to?(:lchmod) -- assert_not_match(/not-implemented/, m.inspect) -- else -- assert_match(/not-implemented/, m.inspect) -- end -- end -- --end --- -2.26.2 - diff --git a/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch b/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch deleted file mode 100644 index b7ea046..0000000 --- a/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 9b42fce32bff25e0569581f76f532b9d57865aef Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?V=C3=ADt=20Ondruch?= -Date: Mon, 27 Jul 2020 14:56:05 +0200 -Subject: [PATCH] Timeout the test_bug_reporter_add witout raising error. - -While timeouting the threads might be still good idea, it does not seems -the timeout impacts the TestBugReporter#test_bug_reporter_add result, -because the output of the child process has been already collected -earlier. - -It seems that when the system is under heavy load, the thread might not -be sheduled to finish its processing. Even finishing the child process -might take tens of seconds and therefore the test case finish might take -a while. ---- - test/-ext-/bug_reporter/test_bug_reporter.rb | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb -index 628fcd0340..2c677cc8a7 100644 ---- a/test/-ext-/bug_reporter/test_bug_reporter.rb -+++ b/test/-ext-/bug_reporter/test_bug_reporter.rb -@@ -17,7 +17,7 @@ def test_bug_reporter_add - args = ["--disable-gems", "-r-test-/bug_reporter", - "-C", tmpdir] - stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$" -- assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT") -+ assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT", timeout_error: nil) - ensure - FileUtils.rm_rf(tmpdir) if tmpdir - end --- -2.27.0 - diff --git a/ruby-2.6.0-rdoc-6.0.2-check-nil-text-token.patch b/ruby-2.6.0-rdoc-6.0.2-check-nil-text-token.patch new file mode 100644 index 0000000..325a6bf --- /dev/null +++ b/ruby-2.6.0-rdoc-6.0.2-check-nil-text-token.patch @@ -0,0 +1,69 @@ +From 9d98bfe7f1abdeda5aedf9404588104980ee7a86 Mon Sep 17 00:00:00 2001 +From: aycabta +Date: Mon, 15 Jan 2018 22:32:56 +0900 +Subject: [PATCH] Check nil text token + +Sometimes :on_ignored_nl token has nil text. This commit checks and +bypasses the token. +--- + lib/rdoc/parser/ripper_state_lex.rb | 4 +++- + test/test_rdoc_parser_ruby.rb | 30 +++++++++++++++++++++++++++++ + 2 files changed, 33 insertions(+), 1 deletion(-) + +diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb +index 2a285b97a4..c56cef46ee 100644 +--- a/lib/rdoc/parser/ripper_state_lex.rb ++++ b/lib/rdoc/parser/ripper_state_lex.rb +@@ -330,8 +330,10 @@ class RDoc::RipperStateLex + @heredoc_queue << retrieve_heredoc_info(tk) + @inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE + when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then +- unless @heredoc_queue.empty? ++ if !@heredoc_queue.empty? + get_heredoc_tk(*@heredoc_queue.shift) ++ elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil ++ tk[:text] = '' + end + when :on_words_beg then + tk = get_words_tk(tk) +diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb +index 833ed2cc74..c9d57021ce 100644 +--- a/test/rdoc/test_rdoc_parser_ruby.rb ++++ b/test/rdoc/test_rdoc_parser_ruby.rb +@@ -306,6 +306,36 @@ def sum(n) + assert_equal @top_level, sum.file + end + ++ def test_parse_on_ignored_nl_with_nil_text ++ util_parser <def meth ++ variable # comment ++ .chain ++end ++EXPECTED ++ expected = expected.rstrip ++ ++ @parser.scan ++ ++ foo = @store.find_class_named 'Foo' ++ meth = foo.method_list.first ++ ++ assert_equal 'meth', meth.name ++ assert_equal @top_level, meth.file ++ ++ markup_code = meth.markup_code.sub(/^.*\n/, '') ++ assert_equal expected, markup_code ++ end ++ + def test_parse_alias + klass = RDoc::NormalClass.new 'Foo' + klass.parent = @top_level diff --git a/ruby-2.6.10-Fix-CVE-2022-28739-Buffer-overrun-in-str2float.patch b/ruby-2.6.10-Fix-CVE-2022-28739-Buffer-overrun-in-str2float.patch new file mode 100644 index 0000000..5c7aec5 --- /dev/null +++ b/ruby-2.6.10-Fix-CVE-2022-28739-Buffer-overrun-in-str2float.patch @@ -0,0 +1,73 @@ +From 8e2ed0b9d965a526b29f9dc3bff8e9fe33dae98d Mon Sep 17 00:00:00 2001 +From: usa +Date: Tue, 12 Apr 2022 11:49:45 +0000 +Subject: [PATCH] Fix CVE-2022-28739 Buffer overrun in str2float. + +CVE-2022-28739: Buffer overrun in String-to-Float conversion +Backported from upstream Ruby 2.6.10, +Git commit: +https://github.com/ruby/ruby/commit/69f9992ed41920389d4185141a14f02f89a4d306 + +==== Original commit message + +Fix dtoa buffer overrun + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + test/ruby/test_float.rb | 18 ++++++++++++++++++ + util.c | 3 ++- + 2 files changed, 20 insertions(+), 1 deletion(-) + +diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb +index 7fabfd3..78c63c2 100644 +--- a/test/ruby/test_float.rb ++++ b/test/ruby/test_float.rb +@@ -171,6 +171,24 @@ class TestFloat < Test::Unit::TestCase + assert_raise(ArgumentError, n += z + "A") {Float(n)} + assert_raise(ArgumentError, n += z + ".0") {Float(n)} + end ++ ++ x = nil ++ 2000.times do ++ x = Float("0x"+"0"*30) ++ break unless x == 0.0 ++ end ++ assert_equal(0.0, x, ->{"%a" % x}) ++ x = nil ++ 2000.times do ++ begin ++ x = Float("0x1."+"0"*270) ++ rescue ArgumentError => e ++ raise unless /"0x1\.0{270}"/ =~ e.message ++ else ++ break ++ end ++ end ++ assert_nil(x, ->{"%a" % x}) + end + + def test_divmod +diff --git a/util.c b/util.c +index 2222744..f1d910f 100644 +--- a/util.c ++++ b/util.c +@@ -2046,6 +2046,7 @@ break2: + if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0; + if (*s == '0') { + while (*++s == '0'); ++ if (!*s) goto ret; + s1 = strchr(hexdigit, *s); + } + if (s1 != NULL) { +@@ -2068,7 +2069,7 @@ break2: + for (; *s && (s1 = strchr(hexdigit, *s)); ++s) { + adj += aadj * ((s1 - hexdigit) & 15); + if ((aadj /= 16) == 0.0) { +- while (strchr(hexdigit, *++s)); ++ while (*++s && strchr(hexdigit, *s)); + break; + } + } +-- +2.41.0 + diff --git a/ruby-2.7.7-Fix-CVE-2021-33621-HTTP-response-splitting-in-CGI.patch b/ruby-2.7.7-Fix-CVE-2021-33621-HTTP-response-splitting-in-CGI.patch new file mode 100644 index 0000000..b30dc6a --- /dev/null +++ b/ruby-2.7.7-Fix-CVE-2021-33621-HTTP-response-splitting-in-CGI.patch @@ -0,0 +1,328 @@ +From 8fc4b4792919c627183f4ddb6dc256aae49eb738 Mon Sep 17 00:00:00 2001 +From: Hiroshi SHIBATA +Date: Tue, 22 Nov 2022 13:48:18 +0900 +Subject: [PATCH] Fix CVE-2021-33621 HTTP response splitting in CGI. + +Backported from upstream Ruby, commit: +https://github.com/ruby/ruby/commit/7cf697179dab52b0d024543304f4d3ab5fa5e847 + +Test "CGICookieTest#test_cgi_cookie_new_with_domain" was adjusted to +deal with Ruby 2.5 not allowing String with double splat operator. + +==== Original commit message +Merge CGI-0.1.0.2 +--- + lib/cgi/cookie.rb | 51 ++++++++++++++++------- + lib/cgi/core.rb | 45 ++++++++++++-------- + test/cgi/test_cgi_cookie.rb | 82 +++++++++++++++++++++++++++++++++++++ + test/cgi/test_cgi_header.rb | 8 ++++ + 4 files changed, 154 insertions(+), 32 deletions(-) + +diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb +index 009566b..f26f015 100644 +--- a/lib/cgi/cookie.rb ++++ b/lib/cgi/cookie.rb +@@ -40,6 +40,10 @@ class CGI + class Cookie < Array + @@accept_charset="UTF-8" unless defined?(@@accept_charset) + ++ TOKEN_RE = %r"\A[[!-~]&&[^()<>@,;:\\\"/?=\[\]{}]]+\z" ++ PATH_VALUE_RE = %r"\A[[ -~]&&[^;]]*\z" ++ DOMAIN_VALUE_RE = %r"\A(?