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

ruby-changes:45144

From: usa <ko1@a...>
Date: Tue, 27 Dec 2016 19:52:40 +0900 (JST)
Subject: [ruby-changes:45144] usa:r57217 (ruby_2_2): merge revision(s) 57078: [Backport #13034]

usa	2016-12-27 19:52:35 +0900 (Tue, 27 Dec 2016)

  New Revision: 57217

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

  Log:
    merge revision(s) 57078: [Backport #13034]
    
    encoding.c: handle needmore error from rb_enc_precise_mbclen()
    
    rb_enc_ascget() erroneously reports success even if the given byte
    sequence is incomplete, for non-ASCII compatible encoding strings.
    
    rb_enc_precise_mbclen() may return a negative value on error, and thus
    rb_enc_ascget() must not store the return value in 'unsigned int';
    otherwise the subsequent MBCLEN_CHARFOUND_P() check won't catch the
    error.  [ruby-core:78646] [Bug #13034]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/encoding.c
    branches/ruby_2_2/test/ruby/test_regexp.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/encoding.c
===================================================================
--- ruby_2_2/encoding.c	(revision 57216)
+++ ruby_2_2/encoding.c	(revision 57217)
@@ -975,7 +975,8 @@ rb_enc_precise_mbclen(const char *p, con https://github.com/ruby/ruby/blob/trunk/ruby_2_2/encoding.c#L975
 int
 rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
 {
-    unsigned int c, l;
+    unsigned int c;
+    int l;
     if (e <= p)
         return -1;
     if (rb_enc_asciicompat(enc)) {
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 57216)
+++ ruby_2_2/ChangeLog	(revision 57217)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Dec 27 19:51:43 2016  Kazuki Yamaguchi  <k@r...>
+
+	* encoding.c (rb_enc_ascget): handle needmore error from
+	  rb_enc_precise_mbclen().
+
+	  rb_enc_ascget() erroneously reports success even if the given byte
+	  sequence is incomplete, for non-ASCII compatible encoding strings.
+
+	  rb_enc_precise_mbclen() may return a negative value on error, and thus
+	  rb_enc_ascget() must not store the return value in 'unsigned int';
+	  otherwise the subsequent MBCLEN_CHARFOUND_P() check won't catch the
+	  error. [Bug #13034]
+
 Tue Dec 27 19:49:01 2016  Shugo Maeda  <shugo@r...>
 
 	* cont.c, eval.c, eval_error.c, thread.c, vm_eval.c, vm_trace.c: add
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 57216)
+++ ruby_2_2/version.h	(revision 57217)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2016-12-27"
-#define RUBY_PATCHLEVEL 407
+#define RUBY_PATCHLEVEL 408
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 12
Index: ruby_2_2/test/ruby/test_regexp.rb
===================================================================
--- ruby_2_2/test/ruby/test_regexp.rb	(revision 57216)
+++ ruby_2_2/test/ruby/test_regexp.rb	(revision 57217)
@@ -492,6 +492,10 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_regexp.rb#L492
     assert_equal("\\v", Regexp.quote("\v"))
     assert_equal("\u3042\\t", Regexp.quote("\u3042\t"))
     assert_equal("\\t\xff", Regexp.quote("\t" + [0xff].pack("C")))
+
+    bug13034 = '[ruby-core:78646] [Bug #13034]'
+    str = "\x00".force_encoding("UTF-16BE")
+    assert_equal(str, Regexp.quote(str), bug13034)
   end
 
   def test_try_convert

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57078


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

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