[前][次][番号順一覧][スレッド一覧]

ruby-changes:41060

From: nagachika <ko1@a...>
Date: Wed, 16 Dec 2015 03:00:34 +0900 (JST)
Subject: [ruby-changes:41060] nagachika:r53135 (ruby_2_2): merge revision(s) 53083:

nagachika	2015-12-16 03:00:02 +0900 (Wed, 16 Dec 2015)

  New Revision: 53135

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53135

  Log:
    merge revision(s) 53083:
    
    * io.c (parse_mode_enc): fix buffer overflow.

  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_io_m17n.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 53134)
+++ ruby_2_2/ChangeLog	(revision 53135)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Wed Dec 16 02:38:19 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (parse_mode_enc): fix buffer overflow.
+
 Sat Dec 12 17:19:27 2015  CHIKANAGA Tomoyuki  <nagachika@r...>
 
 	* doc/NEWS-0.2.2: add description about incompatible change in Hash
Index: ruby_2_2/io.c
===================================================================
--- ruby_2_2/io.c	(revision 53134)
+++ ruby_2_2/io.c	(revision 53135)
@@ -5139,9 +5139,11 @@ parse_mode_enc(const char *estr, rb_enco https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L5139
 	    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_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 53134)
+++ ruby_2_2/version.h	(revision 53135)
@@ -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-12-12"
-#define RUBY_PATCHLEVEL 228
+#define RUBY_RELEASE_DATE "2015-12-16"
+#define RUBY_PATCHLEVEL 229
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 12
+#define RUBY_RELEASE_DAY 16
 
 #include "ruby/version.h"
 
Index: ruby_2_2/test/ruby/test_io_m17n.rb
===================================================================
--- ruby_2_2/test/ruby/test_io_m17n.rb	(revision 53134)
+++ ruby_2_2/test/ruby/test_io_m17n.rb	(revision 53135)
@@ -2083,6 +2083,19 @@ EOT https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_io_m17n.rb#L2083
     }
   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_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53083


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]