]> granicus.if.org Git - onig/commitdiff
number of captures <= 32767 for bytecode representation
authorK.Kosako <kkosako0@gmail.com>
Mon, 15 Aug 2016 07:34:42 +0000 (16:34 +0900)
committerK.Kosako <kkosako0@gmail.com>
Mon, 15 Aug 2016 07:34:42 +0000 (16:34 +0900)
src/oniguruma.h
src/regerror.c
src/regparse.c

index 6e62b50abf6056b953a0e9fb43e6721f18aa73b8..47605c4cede56124946a27a158003631eb62eb92 100644 (file)
@@ -367,6 +367,7 @@ int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
 
 /* config parameters */
 #define ONIG_NREGION                          10
+#define ONIG_MAX_CAPTURE_NUM               32767
 #define ONIG_MAX_BACKREF_NUM                1000
 #define ONIG_MAX_REPEAT_NUM               100000
 #define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
@@ -575,6 +576,7 @@ ONIG_EXTERN OnigSyntaxType*   OnigDefaultSyntax;
 #define ONIGERR_TOO_BIG_BACKREF_NUMBER                       -207
 #define ONIGERR_INVALID_BACKREF                              -208
 #define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED         -209
+#define ONIGERR_TOO_MANY_CAPTURES                            -210
 #define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE                     -212
 #define ONIGERR_EMPTY_GROUP_NAME                             -214
 #define ONIGERR_INVALID_GROUP_NAME                           -215
index 16009bb6d06c977b5ac5996d9f8be778399af0bd..05fc9d8be80508e36ddf1319a2ffa86372bb432e 100644 (file)
@@ -140,6 +140,8 @@ onig_error_code_to_format(int code)
 #endif
   case ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED:
     p = "numbered backref/call is not allowed. (use name)"; break;
+  case ONIGERR_TOO_MANY_CAPTURES:
+    p = "too many captures"; break;
   case ONIGERR_TOO_BIG_WIDE_CHAR_VALUE:
     p = "too big wide-char value"; break;
   case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
index 3fd8d5c0d53dff02c384fe08e7a07b1d9bbd19f7..a32ab9e411d74189b4446590996428e689e0b2c2 100644 (file)
@@ -965,6 +965,9 @@ scan_env_add_mem_entry(ScanEnv* env)
   Node** p;
 
   need = env->num_mem + 1;
+  if (need > ONIG_MAX_CAPTURE_NUM)
+    return ONIGERR_TOO_MANY_CAPTURES;
+
   if (need >= SCANENV_MEMNODES_SIZE) {
     if (env->mem_alloc <= need) {
       if (IS_NULL(env->mem_nodes_dynamic)) {