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

ruby-changes:43089

From: naruse <ko1@a...>
Date: Wed, 25 May 2016 18:45:29 +0900 (JST)
Subject: [ruby-changes:43089] naruse:r55163 (trunk): * regparse.c (fetch_token_in_cc): raise error if given octal escaped

naruse	2016-05-25 18:45:22 +0900 (Wed, 25 May 2016)

  New Revision: 55163

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

  Log:
    * regparse.c (fetch_token_in_cc): raise error if given octal escaped
      character is too big. [Bug #12420] [Bug #12423]

  Modified files:
    trunk/ChangeLog
    trunk/regparse.c
    trunk/test/ruby/test_regexp.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55162)
+++ ChangeLog	(revision 55163)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed May 25 18:30:53 2016  NARUSE, Yui  <naruse@r...>
+
+	* regparse.c (fetch_token_in_cc): raise error if given octal escaped
+	  character is too big. [Bug #12420] [Bug #12423]
+
 Wed May 25 17:45:15 2016  Kazuki Yamaguchi  <k@r...>
 
 	* ext/openssl, test/openssl: Drop OpenSSL < 0.9.8 support.
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 55162)
+++ test/ruby/test_regexp.rb	(revision 55163)
@@ -439,6 +439,8 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L439
     assert_equal(arg_encoding_none, Regexp.new("", nil, "N").options)
 
     assert_raise(RegexpError) { Regexp.new(")(") }
+    assert_raise(RegexpError) { Regexp.new('[\\40000000000') }
+    assert_raise(RegexpError) { Regexp.new('[\\600000000000.') }
   end
 
   def test_unescape
Index: regparse.c
===================================================================
--- regparse.c	(revision 55162)
+++ regparse.c	(revision 55163)
@@ -3229,7 +3229,7 @@ fetch_token_in_cc(OnigToken* tok, UChar* https://github.com/ruby/ruby/blob/trunk/regparse.c#L3229
 	PUNFETCH;
 	prev = p;
 	num = scan_unsigned_octal_number(&p, end, 3, enc);
-	if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (num < 0 || 0xff < num) return ONIGERR_TOO_BIG_NUMBER;
 	if (p == prev) {  /* can't read nothing. */
 	  num = 0; /* but, it's not error */
 	}

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

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