ruby-changes:41073
From: usa <ko1@a...>
Date: Wed, 16 Dec 2015 16:15:02 +0900 (JST)
Subject: [ruby-changes:41073] usa:r53148 (ruby_2_1): merge revision(s) 53083: [Backport #11823]
usa 2015-12-16 16:14:32 +0900 (Wed, 16 Dec 2015) New Revision: 53148 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53148 Log: merge revision(s) 53083: [Backport #11823] * io.c (parse_mode_enc): fix buffer overflow. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/io.c branches/ruby_2_1/test/ruby/test_io_m17n.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 53147) +++ ruby_2_1/ChangeLog (revision 53148) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Wed Dec 16 16:13:04 2015 Nobuyoshi Nakada <nobu@r...> + + * io.c (parse_mode_enc): fix buffer overflow. + Wed Dec 16 16:10:52 2015 Eric Wong <e@8...> * insns.def (opt_case_dispatch): avoid converting Infinity Index: ruby_2_1/io.c =================================================================== --- ruby_2_1/io.c (revision 53147) +++ ruby_2_1/io.c (revision 53148) @@ -5059,9 +5059,11 @@ parse_mode_enc(const char *estr, rb_enco https://github.com/ruby/ruby/blob/trunk/ruby_2_1/io.c#L5059 fmode |= FMODE_SETENC_BY_BOM; estr += 4; len -= 4; - memcpy(encname, estr, len); - encname[len] = '\0'; - estr = encname; + if (len > 0 && len <= ENCODING_MAXNAMELEN) { + memcpy(encname, estr, len); + encname[len] = '\0'; + estr = encname; + } } idx = rb_enc_find_index(estr); } Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 53147) +++ ruby_2_1/version.h (revision 53148) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.8" #define RUBY_RELEASE_DATE "2015-12-16" -#define RUBY_PATCHLEVEL 437 +#define RUBY_PATCHLEVEL 438 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 12 Index: ruby_2_1/test/ruby/test_io_m17n.rb =================================================================== --- ruby_2_1/test/ruby/test_io_m17n.rb (revision 53147) +++ ruby_2_1/test/ruby/test_io_m17n.rb (revision 53148) @@ -2073,6 +2073,19 @@ EOT https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_io_m17n.rb#L2073 } end + def test_bom_too_long_utfname + assert_separately([], <<-'end;') # do + assert_warn(/Unsupported encoding/) { + open(IO::NULL, "r:bom|utf-" + "x" * 10000) {} + } + end; + assert_separately([], <<-'end;') # do + assert_warn(/Unsupported encoding/) { + open(IO::NULL, encoding: "bom|utf-" + "x" * 10000) {} + } + end; + end + def test_cbuf with_tmpdir { fn = "tst" Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53083 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/