From 88387876af112eb0bdefe7408bca6aaaacf52d6f Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 1 Oct 2019 11:04:48 +0000 Subject: [PATCH] merge revision(s) a0a2640b398cffd351f87d3f6243103add66575b Fix for wrong fnmatch patttern * dir.c (file_s_fnmatch): ensure that pattern does not contain a NUL character. https://hackerone.com/reports/449617 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@67817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 2 +- test/ruby/test_fnmatch.rb | 6 ++++++ version.h | 10 +++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dir.c b/dir.c index 0b83fc4df8..547921447d 100644 --- a/dir.c +++ b/dir.c @@ -2655,7 +2655,7 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj) else flags = 0; - StringValue(pattern); + StringValueCStr(pattern); FilePathStringValue(path); if (flags & FNM_EXTGLOB) { diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb index ca01a28698..30250b5a19 100644 --- a/test/ruby/test_fnmatch.rb +++ b/test/ruby/test_fnmatch.rb @@ -129,4 +129,10 @@ class TestFnmatch < Test::Unit::TestCase assert_file.fnmatch("[a-\u3042]*", "\u3042") assert_file.not_fnmatch("[a-\u3042]*", "\u3043") end + + def test_nullchar + assert_raise(ArgumentError) { + File.fnmatch("a\0z", "a") + } + end end diff --git a/version.h b/version.h index 1e7b1e87ca..b162c53921 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ -#define RUBY_VERSION "2.4.7" -#define RUBY_RELEASE_DATE "2019-08-28" -#define RUBY_PATCHLEVEL 357 +#define RUBY_VERSION "2.4.8" +#define RUBY_RELEASE_DATE "2019-10-01" +#define RUBY_PATCHLEVEL 358 #define RUBY_RELEASE_YEAR 2019 -#define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_MONTH 10 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h"