ruby-changes:40571
From: nagachika <ko1@a...>
Date: Thu, 19 Nov 2015 00:11:06 +0900 (JST)
Subject: [ruby-changes:40571] nagachika:r52650 (ruby_2_2): merge revision(s) 52211: [Backport #11610] [Backport #11637]
nagachika 2015-11-19 00:10:54 +0900 (Thu, 19 Nov 2015) New Revision: 52650 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52650 Log: merge revision(s) 52211: [Backport #11610] [Backport #11637] * io.c (argf_next_argv): check ARGV element type, and try conversion if necessary. [ruby-core:71140] [Bug #11610] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/io.c branches/ruby_2_2/test/ruby/test_argf.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 52649) +++ ruby_2_2/ChangeLog (revision 52650) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Thu Nov 19 00:01:14 2015 Nobuyoshi Nakada <nobu@r...> + + * io.c (argf_next_argv): check ARGV element type, and try + conversion if necessary. [ruby-core:71140] [Bug #11610] + Wed Nov 18 23:29:32 2015 Aaron Patterson <tenderlove@r...> * ext/openssl/ossl_ssl.c (ossl_ssl_method_tab): Only add SSLv3 support Index: ruby_2_2/io.c =================================================================== --- ruby_2_2/io.c (revision 52649) +++ ruby_2_2/io.c (revision 52650) @@ -7920,9 +7920,11 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7920 if (ARGF.next_p == 1) { retry: if (RARRAY_LEN(ARGF.argv) > 0) { - ARGF.filename = rb_str_encode_ospath(rb_ary_shift(ARGF.argv)); - fn = StringValueCStr(ARGF.filename); - if (strlen(fn) == 1 && fn[0] == '-') { + VALUE filename = rb_ary_shift(ARGF.argv); + StringValueCStr(filename); + ARGF.filename = rb_str_encode_ospath(filename); + fn = StringValueCStr(filename); + if (RSTRING_LEN(filename) == 1 && fn[0] == '-') { ARGF.current_file = rb_stdin; if (ARGF.inplace) { rb_warn("Can't do inplace edit for stdio; skipping"); @@ -7931,7 +7933,7 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7933 } else { VALUE write_io = Qnil; - int fr = rb_sysopen(ARGF.filename, O_RDONLY, 0); + int fr = rb_sysopen(filename, O_RDONLY, 0); if (ARGF.inplace) { struct stat st; @@ -7945,7 +7947,7 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7947 rb_io_close(rb_stdout); } fstat(fr, &st); - str = ARGF.filename; + str = filename; if (*ARGF.inplace) { str = rb_str_dup(str); rb_str_cat2(str, ARGF.inplace); @@ -7955,14 +7957,14 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7957 (void)unlink(RSTRING_PTR(str)); if (rename(fn, RSTRING_PTR(str)) < 0) { rb_warn("Can't rename %"PRIsVALUE" to %"PRIsVALUE": %s, skipping file", - ARGF.filename, str, strerror(errno)); + filename, str, strerror(errno)); goto retry; } fr = rb_sysopen(str, O_RDONLY, 0); #else if (rename(fn, RSTRING_PTR(str)) < 0) { rb_warn("Can't rename %"PRIsVALUE" to %"PRIsVALUE": %s, skipping file", - ARGF.filename, str, strerror(errno)); + filename, str, strerror(errno)); close(fr); goto retry; } @@ -7974,13 +7976,13 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7976 #else if (unlink(fn) < 0) { rb_warn("Can't remove %"PRIsVALUE": %s, skipping file", - ARGF.filename, strerror(errno)); + filename, strerror(errno)); close(fr); goto retry; } #endif } - fw = rb_sysopen(ARGF.filename, O_WRONLY|O_CREAT|O_TRUNC, 0666); + fw = rb_sysopen(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666); #ifndef NO_SAFE_RENAME fstat(fw, &st2); #ifdef HAVE_FCHMOD @@ -7996,9 +7998,9 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L7998 err = chown(fn, st.st_uid, st.st_gid); #endif if (err && getuid() == 0 && st2.st_uid == 0) { - const char *wkfn = RSTRING_PTR(ARGF.filename); + const char *wkfn = RSTRING_PTR(filename); rb_warn("Can't set owner/group of %"PRIsVALUE" to same as %"PRIsVALUE": %s, skipping file", - ARGF.filename, str, strerror(errno)); + filename, str, strerror(errno)); (void)close(fr); (void)close(fw); (void)unlink(wkfn); Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 52649) +++ ruby_2_2/version.h (revision 52650) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.4" -#define RUBY_RELEASE_DATE "2015-11-18" -#define RUBY_PATCHLEVEL 188 +#define RUBY_RELEASE_DATE "2015-11-19" +#define RUBY_PATCHLEVEL 189 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" Index: ruby_2_2/test/ruby/test_argf.rb =================================================================== --- ruby_2_2/test/ruby/test_argf.rb (revision 52649) +++ ruby_2_2/test/ruby/test_argf.rb (revision 52650) @@ -856,4 +856,12 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_argf.rb#L856 assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read)) end end + + def test_wrong_type + assert_separately([], <<-'end;') + bug11610 = '[ruby-core:71140] [Bug #11610]' + ARGV[0] = nil + assert_raise(TypeError, bug11610) {gets} + end; + end end Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r52211 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/