Po-Chuan Hsieh 2022-09-11 00:07:01 +08:00
parent 0d5e0ad514
commit 73216b1ead
No known key found for this signature in database
GPG Key ID: 9A4BD10F002DD04B
7 changed files with 771 additions and 522 deletions

View File

@ -155,8 +155,8 @@ RUBY_PORTEPOCH= 1
#
# Ruby 3.2
#
RUBY_DISTVERSION= 3.2.0-preview1
RUBY_PORTREVISION= 2
RUBY_DISTVERSION= 3.2.0-preview2
RUBY_PORTREVISION= 0
RUBY_PORTEPOCH= 1
# When adding a version, please keep the comment in

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1649009344
SHA256 (ruby/ruby-3.2.0-preview1.tar.xz) = 6d28477f7fa626b63bf139afd37bcfeb28fce6847b203fa10f37cb3615d0c35d
SIZE (ruby/ruby-3.2.0-preview1.tar.xz) = 15011400
TIMESTAMP = 1662820136
SHA256 (ruby/ruby-3.2.0-preview2.tar.xz) = 01fac0929dccdabc0686c1109da6c187897a401da9ff8851242befa92f7fd430
SIZE (ruby/ruby-3.2.0-preview2.tar.xz) = 14578112

View File

@ -1,66 +0,0 @@
From cf2bbcfff2985c116552967c7c4522f4630f2d18 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Fri, 11 Jun 2021 00:06:43 +0900
Subject: [PATCH 1/2] Just free compiled pattern if no space is used
https://hackerone.com/reports/1220911
---
regcomp.c | 14 ++++++++------
test/ruby/test_regexp.rb | 9 +++++++++
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git regcomp.c regcomp.c
index 3e65c9d2e3..94640639d8 100644
--- regcomp.c
+++ regcomp.c
@@ -142,8 +142,13 @@ bitset_on_num(BitSetRef bs)
static void
onig_reg_resize(regex_t *reg)
{
- resize:
- if (reg->alloc > reg->used) {
+ do {
+ if (!reg->used) {
+ xfree(reg->p);
+ reg->alloc = 0;
+ reg->p = 0;
+ }
+ else if (reg->alloc > reg->used) {
unsigned char *new_ptr = xrealloc(reg->p, reg->used);
// Skip the right size optimization if memory allocation fails
if (new_ptr) {
@@ -151,10 +156,7 @@ onig_reg_resize(regex_t *reg)
reg->p = new_ptr;
}
}
- if (reg->chain) {
- reg = reg->chain;
- goto resize;
- }
+ } while ((reg = reg->chain) != 0);
}
extern int
diff --git test/ruby/test_regexp.rb test/ruby/test_regexp.rb
index 4be6d7bec7..84687c5380 100644
--- test/ruby/test_regexp.rb
+++ test/ruby/test_regexp.rb
@@ -1431,6 +1431,15 @@ def test_bug18631
assert_kind_of MatchData, /(?<x>a)(?<x>aa)\k<x>/.match("aaaab")
end
+ def test_invalid_group
+ assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}")
+ begin;
+ assert_raise_with_message(RegexpError, /invalid conditional pattern/) do
+ Regexp.new("((?(1)x|x|)x)+")
+ end
+ end;
+ end
+
# This assertion is for porting x2() tests in testpy.py of Onigmo.
def assert_match_at(re, str, positions, msg = nil)
re = Regexp.new(re) unless re.is_a?(Regexp)
--
2.35.2

View File

@ -1,64 +0,0 @@
From d0a822eec524522d81ffc7da2bb1baf906b0318a Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Thu, 1 Jul 2021 06:39:17 +0900
Subject: [PATCH 2/2] Fix dtoa buffer overrun
https://hackerone.com/reports/1248108
---
missing/dtoa.c | 3 ++-
test/ruby/test_float.rb | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git missing/dtoa.c missing/dtoa.c
index a940eabd91..b7a8302875 100644
--- missing/dtoa.c
+++ missing/dtoa.c
@@ -1552,6 +1552,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) {
@@ -1574,7 +1575,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;
}
}
diff --git test/ruby/test_float.rb test/ruby/test_float.rb
index 4be2cfeeda..57a46fce92 100644
--- test/ruby/test_float.rb
+++ test/ruby/test_float.rb
@@ -171,6 +171,24 @@ def test_strtod
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
--
2.35.2

View File

@ -1,6 +1,6 @@
--- tool/rbinstall.rb.orig 2021-12-25 12:23:14 UTC
--- tool/rbinstall.rb.orig 2022-09-08 21:09:50 UTC
+++ tool/rbinstall.rb
@@ -923,188 +923,6 @@ end
@@ -906,152 +906,6 @@ end
# :startdoc:
@ -11,13 +11,12 @@
- install_default_gem('ext', srcdir, bindir)
-end
-
-def load_gemspec(file, expanded = false)
-def load_gemspec(file, base = nil)
- file = File.realpath(file)
- code = File.read(file, encoding: "utf-8:-")
- code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
- files = []
- if expanded
- base = File.dirname(file)
- if base
- Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
- case File.basename(n); when ".", ".."; next; end
- next if File.directory?(File.join(base, n))
@ -30,8 +29,9 @@
- unless Gem::Specification === spec
- raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
- end
- spec.loaded_from = file
- spec.loaded_from = base ? File.join(base, File.basename(file)) : file
- spec.files.reject! {|n| n.end_with?(".gemspec") or n.start_with?(".git")}
- spec.date = RUBY_RELEASE_DATE
-
- spec
-end
@ -57,9 +57,10 @@
- }
- default_spec_dir = Gem.default_specifications_dir
-
- gems = Dir.glob("#{srcdir}/#{dir}/**/*.gemspec").map {|src|
- spec = load_gemspec(src)
- file_collector = RbInstall::Specs::FileCollector.new(src)
- base = "#{srcdir}/#{dir}"
- gems = Dir.glob("**/*.gemspec", base: base).map {|src|
- spec = load_gemspec("#{base}/#{src}")
- file_collector = RbInstall::Specs::FileCollector.for(srcdir, dir, src)
- files = file_collector.collect
- if file_collector.skip_install?(files)
- next
@ -85,20 +86,6 @@
-end
-
-install?(:ext, :comm, :gem, :'bundled-gems') do
- if CONFIG['CROSS_COMPILING'] == 'yes'
- # The following hacky steps set "$ruby = BASERUBY" in tool/fake.rb
- $hdrdir = ''
- $extmk = nil
- $ruby = nil # ...
- ruby_path = $ruby + " -I#{Dir.pwd}" # $baseruby + " -I#{Dir.pwd}"
- else
- # ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name)))
- ENV['RUBYLIB'] = nil
- ENV['RUBYOPT'] = nil
- ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name))) + " --disable=gems -I#{with_destdir(archlibdir)}"
- end
- Gem.instance_variable_set(:@ruby, ruby_path) if Gem.ruby != ruby_path
-
- gem_dir = Gem.default_dir
- install_dir = with_destdir(gem_dir)
- prepare "bundled gems", gem_dir
@ -118,40 +105,38 @@
- :wrappers => true,
- :format_executable => true,
- }
- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}"
- extensions_dir = with_destdir(Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir)
-
- extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir
- specifications_dir = File.join(gem_dir, "specifications")
- build_dir = Gem::StubSpecification.gemspec_stub("", ".bundle", ".bundle").extensions_dir
-
- # We are about to build extensions, and want to configure extensions with the
- # newly installed ruby.
- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name)))
- # Prevent fake.rb propagation. It conflicts with the natural mkmf configs of
- # the newly installed ruby.
- ENV.delete('RUBYOPT')
-
- File.foreach("#{srcdir}/gems/bundled_gems") do |name|
- next if /^\s*(?:#|$)/ =~ name
- next unless /^(\S+)\s+(\S+).*/ =~ name
- gem_name = "#$1-#$2"
- path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
- if File.exist?(path)
- spec = load_gemspec(path)
- else
- path = "#{srcdir}/.bundle/gems/#{gem_name}/#$1.gemspec"
- path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
- unless File.exist?(path)
- path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
- next unless File.exist?(path)
- spec = load_gemspec(path, true)
- end
- spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
- next unless spec.platform == Gem::Platform::RUBY
- next unless spec.full_name == gem_name
- if !spec.extensions.empty? && CONFIG["EXTSTATIC"] == "static"
- puts "skip installation of #{spec.name} #{spec.version}; bundled gem with an extension library is not supported on --with-static-linked-ext"
- next
- end
- spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
- spec.extensions[0] ||= "-"
- end
- package = RbInstall::DirPackage.new spec
- ins = RbInstall::UnpackedInstaller.new(package, options)
- puts "#{INDENT}#{spec.name} #{spec.version}"
- ins.install
- unless $dryrun
- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
- end
- unless spec.extensions.empty?
- install_recursive(ext, spec.extension_dir)
- install_recursive("#{build_dir}/#{gem_name}", "#{extensions_dir}/#{gem_name}") do |src, dest|
- # puts "#{INDENT} #{dest[extensions_dir.size+gem_name.size+2..-1]}"
- install src, dest, :mode => (File.executable?(src) ? $prog_mode : $data_mode)
- end
- installed_gems[spec.full_name] = true
- end
@ -160,29 +145,8 @@
- prepare "bundled gem cache", gem_dir+"/cache"
- install installed_gems, gem_dir+"/cache"
- end
- next if gems.empty?
- if defined?(Zlib)
- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name)))
- silent = Gem::SilentUI.new
- gems.each do |gem|
- package = Gem::Package.new(gem)
- inst = RbInstall::GemInstaller.new(package, options)
- inst.spec.extension_dir = "#{extensions_dir}/#{inst.spec.full_name}"
- begin
- Gem::DefaultUserInteraction.use_ui(silent) {inst.install}
- rescue Gem::InstallError
- next
- end
- gemname = File.basename(gem)
- puts "#{INDENT}#{gemname}"
- end
- # fix directory permissions
- # TODO: Gem.install should accept :dir_mode option or something
- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/"))
- # fix .gemspec permissions
- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec"))
- else
- puts "skip installing bundled gems because of lacking zlib"
- unless gems.empty?
- puts "skipped bundled gems: #{gems.join(' ')}"
- end
-end
-

View File

@ -1,29 +0,0 @@
--- util.c.orig 2022-04-12 11:48:55 UTC
+++ util.c
@@ -214,6 +214,7 @@ typedef int (cmpfunc_t)(const void*, const void*, void
typedef int (cmpfunc_t)(const void*, const void*, void*);
+#if !defined HAVE_GNU_QSORT_R
#if defined HAVE_QSORT_S && defined RUBY_MSVCRT_VERSION
/* In contrast to its name, Visual Studio qsort_s is incompatible with
* C11 in the order of the comparison function's arguments, and same
@@ -259,7 +260,7 @@ ruby_qsort(void* base, const size_t nel, const size_t
qsort_s(base, nel, size, cmp, d);
}
# define HAVE_GNU_QSORT_R 1
-#elif !defined HAVE_GNU_QSORT_R
+#else
/* mm.c */
#define mmtype long
@@ -525,7 +526,8 @@ ruby_qsort(void* base, const size_t nel, const size_t
else goto nxt; /* need not to sort both sides */
}
}
-#endif /* HAVE_GNU_QSORT_R */
+#endif
+#endif /* !HAVE_GNU_QSORT_R */
char *
ruby_strdup(const char *str)

File diff suppressed because it is too large Load Diff