ruby-changes:50809
From: usa <ko1@a...>
Date: Wed, 28 Mar 2018 23:27:57 +0900 (JST)
Subject: [ruby-changes:50809] usa:r63015 (ruby_2_2): merge revision(s) 62989:
usa 2018-03-28 23:27:51 +0900 (Wed, 28 Mar 2018) New Revision: 63015 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63015 Log: merge revision(s) 62989: dir.c: check NUL bytes * dir.c (GlobPathValue): should be used in rb_push_glob only. other methods should use FilePathValue. https://hackerone.com/reports/302338 * dir.c (rb_push_glob): expand GlobPathValue Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/dir.c branches/ruby_2_2/test/ruby/test_dir.rb branches/ruby_2_2/version.h Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 63014) +++ ruby_2_2/version.h (revision 63015) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 -#define RUBY_VERSION "2.2.9" -#define RUBY_RELEASE_DATE "2018-02-17" -#define RUBY_PATCHLEVEL 482 +#define RUBY_VERSION "2.2.10" +#define RUBY_RELEASE_DATE "2018-03-28" +#define RUBY_PATCHLEVEL 483 #define RUBY_RELEASE_YEAR 2018 -#define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_MONTH 3 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" Index: ruby_2_2/test/ruby/test_dir.rb =================================================================== --- ruby_2_2/test/ruby/test_dir.rb (revision 63014) +++ ruby_2_2/test/ruby/test_dir.rb (revision 63015) @@ -149,6 +149,9 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_dir.rb#L149 assert_equal([File.join(@root, "a")], Dir.glob(File.join(@root, 'a\\'))) assert_equal((?a..?f).map {|f| File.join(@root, f) }.sort, Dir.glob(File.join(@root, '[abc/def]')).sort) + assert_raise(ArgumentError) { + Dir.glob([[@root, File.join(@root, "*")].join("\0")]) + } end def test_glob_recursive @@ -179,6 +182,7 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_dir.rb#L182 def test_foreach assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a) + assert_raise(ArgumentError) {Dir.foreach(@root+"\0").to_a} end def test_dir_enc Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 63014) +++ ruby_2_2/ChangeLog (revision 63015) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Wed Mar 28 23:27:23 2018 Nobuyoshi Nakada <nobu@r...> + + dir.c: check NUL bytes + + * dir.c (GlobPathValue): should be used in rb_push_glob only. + other methods should use FilePathValue. + https://hackerone.com/reports/302338 + + * dir.c (rb_push_glob): expand GlobPathValue + Sat Feb 17 01:24:49 2018 SHIBATA Hiroshi <hsbt@r...> Merge RubyGems 2.7.6 from upstream. Index: ruby_2_2/dir.c =================================================================== --- ruby_2_2/dir.c (revision 63014) +++ ruby_2_2/dir.c (revision 63015) @@ -423,15 +423,6 @@ static const rb_data_type_t dir_data_typ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L423 static VALUE dir_close(VALUE); -#define GlobPathValue(str, safe) \ - /* can contain null bytes as separators */ \ - (!RB_TYPE_P((str), T_STRING) ? \ - (void)FilePathValue(str) : \ - (void)(check_safe_glob((str), (safe)), \ - check_glob_encoding(str), (str))) -#define check_safe_glob(str, safe) ((safe) ? rb_check_safe_obj(str) : (void)0) -#define check_glob_encoding(str) rb_enc_check((str), rb_enc_from_encoding(rb_usascii_encoding())) - static VALUE dir_s_alloc(VALUE klass) { @@ -480,7 +471,7 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L471 } } - GlobPathValue(dirname, FALSE); + FilePathValue(dirname); orig = rb_str_dup_frozen(dirname); dirname = rb_str_encode_ospath(dirname); dirname = rb_str_dup_frozen(dirname); @@ -2050,7 +2041,14 @@ rb_push_glob(VALUE str, int flags) /* '\ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L2041 long offset = 0; VALUE ary; - GlobPathValue(str, TRUE); + /* can contain null bytes as separators */ + if (!RB_TYPE_P((str), T_STRING)) { + FilePathValue(str); + } + else { + rb_check_safe_obj(str); + rb_enc_check(str, rb_enc_from_encoding(rb_usascii_encoding())); + } ary = rb_ary_new(); while (offset < RSTRING_LEN(str)) { @@ -2080,7 +2078,7 @@ dir_globs(long argc, const VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L2078 for (i = 0; i < argc; ++i) { int status; VALUE str = argv[i]; - GlobPathValue(str, TRUE); + FilePathValue(str); status = push_glob(ary, str, flags); if (status) GLOB_JUMP_TAG(status); } Index: ruby_2_2 =================================================================== --- ruby_2_2 (revision 63014) +++ ruby_2_2 (revision 63015) Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62989 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/