andrei          Fri Apr  7 21:20:10 2006 UTC

  Modified files:              
    /php-src/ext/pcre   TODO php_pcre.c 
  Log:
  Disallowed numeric named captures.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/TODO?r1=1.5&r2=1.6&diff_format=u
Index: php-src/ext/pcre/TODO
diff -u php-src/ext/pcre/TODO:1.5 php-src/ext/pcre/TODO:1.6
--- php-src/ext/pcre/TODO:1.5   Thu Apr  6 22:37:42 2006
+++ php-src/ext/pcre/TODO       Fri Apr  7 21:20:10 2006
@@ -32,6 +32,4 @@
   of a grep function in PHP would be that the default is PREG_GREP_REKEY_NUMS
   or PREG_GREP_REKEY_ALL....
 
-- Disallow numeric named captures.
-
 
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.c?r1=1.179&r2=1.180&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.179 php-src/ext/pcre/php_pcre.c:1.180
--- php-src/ext/pcre/php_pcre.c:1.179   Thu Apr  6 21:16:28 2006
+++ php-src/ext/pcre/php_pcre.c Fri Apr  7 21:20:10 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.179 2006/04/06 21:16:28 andrei Exp $ */
+/* $Id: php_pcre.c,v 1.180 2006/04/07 21:20:10 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -464,7 +464,7 @@
 
        /*
         * Build a mapping from subpattern numbers to their names. We will 
always
-        * allocate the table, even though they may be no named subpatterns. 
This
+        * allocate the table, even though there may be no named subpatterns. 
This
         * avoids somewhat more complicated logic in the inner loops.
         */
        subpat_names = (char **)safe_emalloc(num_subpats, sizeof(char *), 0);
@@ -478,22 +478,34 @@
                if (rc < 0) {
                        php_error(E_WARNING, "%s: internal pcre_fullinfo() 
error %d",
                                          get_active_function_name(TSRMLS_C), 
rc);
+                       efree(offsets);
+                       efree(subpat_names);
                        RETURN_FALSE;
                }
                if (name_cnt > 0) {
                        int rc1, rc2;
+                       long dummy_l;
+                       double dummy_d;
                        rc1 = pcre_fullinfo(re, extra, PCRE_INFO_NAMETABLE, 
&name_table);
                        rc2 = pcre_fullinfo(re, extra, PCRE_INFO_NAMEENTRYSIZE, 
&name_size);
                        rc = rc2 ? rc2 : rc1;
                        if (rc < 0) {
                                php_error(E_WARNING, "%s: internal 
pcre_fullinfo() error %d",
                                                  
get_active_function_name(TSRMLS_C), rc);
+                               efree(offsets);
+                               efree(subpat_names);
                                RETURN_FALSE;
                        }
 
                        while (ni++ < name_cnt) {
                                name_idx = 0xff * name_table[0] + name_table[1];
                                subpat_names[name_idx] = name_table + 2;
+                               if (is_numeric_string(subpat_names[name_idx], 
strlen(subpat_names[name_idx]), &dummy_l, &dummy_d, 0) > 0) {
+                                       php_error(E_WARNING, "%s: numeric named 
subpatterns are not allowed", get_active_function_name(TSRMLS_C));
+                                       efree(offsets);
+                                       efree(subpat_names);
+                                       RETURN_FALSE;
+                               }
                                name_table += name_size;
                        }
                }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to