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

ruby-changes:35318

From: usa <ko1@a...>
Date: Fri, 5 Sep 2014 13:42:20 +0900 (JST)
Subject: [ruby-changes:35318] usa:r47400 (ruby_2_0_0): merge r46831 partially. these changes are from:

usa	2014-09-05 13:42:09 +0900 (Fri, 05 Sep 2014)

  New Revision: 47400

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

  Log:
    merge r46831 partially.  these changes are from:
    https://github.com/k-takata/Onigmo/commit/7abd7b29481f98eb92be786e3d33611fc7d000a0
    [Bug #8716]
    
    * include/ruby/oniguruma.h (ONIG_MAX_CAPTURE_GROUP_NUM,
      ONIGERR_TOO_MANY_CAPTURE_GROUPS): add cheking the number of capture
      groups.
    
    * regerror.c (onig_error_code_to_format): ditto.
    
    * regparse.c (scan_env_add_mem_entry): ditto.
    
    * regexec.c (onig_region_copy, match_at): fix: segmation fault occurs
      when many groups are used.

  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/include/ruby/oniguruma.h
    branches/ruby_2_0_0/regerror.c
    branches/ruby_2_0_0/regint.h
    branches/ruby_2_0_0/regparse.c
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/regparse.c
===================================================================
--- ruby_2_0_0/regparse.c	(revision 47399)
+++ ruby_2_0_0/regparse.c	(revision 47400)
@@ -978,6 +978,8 @@ scan_env_add_mem_entry(ScanEnv* env) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regparse.c#L978
   Node** p;
 
   need = env->num_mem + 1;
+  if (need > ONIG_MAX_CAPTURE_GROUP_NUM)
+    return ONIGERR_TOO_MANY_CAPTURE_GROUPS;
   if (need >= SCANENV_MEMNODES_SIZE) {
     if (env->mem_alloc <= need) {
       if (IS_NULL(env->mem_nodes_dynamic)) {
@@ -4960,14 +4962,9 @@ parse_enclose(Node** np, OnigToken* tok, https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regparse.c#L4962
 	*np = node_new_enclose_memory(env->option, 0);
 	CHECK_NULL_RETURN_MEMERR(*np);
 	num = scan_env_add_mem_entry(env);
-	if (num < 0) {
-	  onig_node_free(*np);
-	  return num;
-	}
-	else if (num >= (int )BIT_STATUS_BITS_NUM) {
-	  onig_node_free(*np);
+	if (num < 0) return num;
+	if (num >= (int )BIT_STATUS_BITS_NUM)
 	  return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
-	}
 	NENCLOSE(*np)->regnum = num;
 	BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
       }
Index: ruby_2_0_0/include/ruby/oniguruma.h
===================================================================
--- ruby_2_0_0/include/ruby/oniguruma.h	(revision 47399)
+++ ruby_2_0_0/include/ruby/oniguruma.h	(revision 47400)
@@ -340,6 +340,7 @@ int onigenc_str_bytelen_null P_((OnigEnc https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/include/ruby/oniguruma.h#L340
 /* config parameters */
 #define ONIG_NREGION                          10
 #define ONIG_MAX_BACKREF_NUM                1000
+#define ONIG_MAX_CAPTURE_GROUP_NUM         32767
 #define ONIG_MAX_REPEAT_NUM               100000
 #define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
 /* constants */
@@ -584,6 +585,7 @@ ONIG_EXTERN const OnigSyntaxType*   Onig https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/include/ruby/oniguruma.h#L585
 #define ONIGERR_NEVER_ENDING_RECURSION                       -221
 #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY        -222
 #define ONIGERR_INVALID_CHAR_PROPERTY_NAME                   -223
+#define ONIGERR_TOO_MANY_CAPTURE_GROUPS                      -224
 #define ONIGERR_INVALID_CODE_POINT_VALUE                     -400
 #define ONIGERR_INVALID_WIDE_CHAR_VALUE                      -400
 #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 47399)
+++ ruby_2_0_0/ChangeLog	(revision 47400)
@@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Fri Sep  5 13:36:12 2014  NAKAMURA Usaku  <usa@r...>
+
+	merge r46831 partially.  these changes are from:
+	https://github.com/k-takata/Onigmo/commit/7abd7b29481f98eb92be786e3d33611fc7d000a0
+	[Bug #8716]
+
+	* include/ruby/oniguruma.h (ONIG_MAX_CAPTURE_GROUP_NUM,
+	  ONIGERR_TOO_MANY_CAPTURE_GROUPS): add cheking the number of capture
+	  groups.
+
+	* regerror.c (onig_error_code_to_format): ditto.
+
+	* regparse.c (scan_env_add_mem_entry): ditto.
+
+	* regexec.c (onig_region_copy, match_at): fix: segmation fault occurs
+	  when many groups are used.
+
 Fri Sep  5 13:06:53 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (rb_str_resize): update capa only when buffer get
Index: ruby_2_0_0/regerror.c
===================================================================
--- ruby_2_0_0/regerror.c	(revision 47399)
+++ ruby_2_0_0/regerror.c	(revision 47400)
@@ -133,6 +133,8 @@ onig_error_code_to_format(OnigPosition c https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regerror.c#L133
     p = "too short multibyte code string"; break;
   case ONIGERR_TOO_BIG_BACKREF_NUMBER:
     p = "too big backref number"; break;
+  case ONIGERR_TOO_MANY_CAPTURE_GROUPS:
+    p = "too many capture groups are specified"; break;
   case ONIGERR_INVALID_BACKREF:
 #ifdef USE_NAMED_GROUP
     p = "invalid backref number/name"; break;
Index: ruby_2_0_0/regint.h
===================================================================
--- ruby_2_0_0/regint.h	(revision 47399)
+++ ruby_2_0_0/regint.h	(revision 47400)
@@ -239,8 +239,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regint.h#L239
 # include <stddef.h>
 #endif
 
-#ifdef __BORLANDC__
-#include <malloc.h>
+#ifdef _WIN32
+#include <malloc.h>	/* for alloca() */
 #endif
 
 #ifdef ONIG_DEBUG
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 47399)
+++ ruby_2_0_0/version.h	(revision 47400)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-09-05"
-#define RUBY_PATCHLEVEL 549
+#define RUBY_PATCHLEVEL 550
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 9

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

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