cvs: php4 /ext/pcre php_pcre.c
| From: | Andrei Zmievski | Date: | Thu, 14 Sep 2000 15:44:36 +0000 |
| Subject: | cvs: php4 /ext/pcre php_pcre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1756@lists.php.net to get a copy of this message | ||
andrei Thu Sep 14 08:44:36 2000 EDT
Modified files:
/php4/ext/pcre php_pcre.c
Log:
Fixed bug #6740.
I happen to think that this is php_addslashes() problem, not PCRE's.
When 0 is passed for the length of the string to php_addslashes() it
assumes that we want to process the whole string and happily runs
strlen() on it. That is bad. It should respect the length and return
an empty string if it's 0.
Index: php4/ext/pcre/php_pcre.c
diff -u php4/ext/pcre/php_pcre.c:1.68 php4/ext/pcre/php_pcre.c:1.69
--- php4/ext/pcre/php_pcre.c:1.68 Tue Sep 12 13:48:33 2000
+++ php4/ext/pcre/php_pcre.c Thu Sep 14 08:44:36 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.68 2000/09/12 20:48:33 zeev Exp $ */
+/* $Id: php_pcre.c,v 1.69 2000/09/14 15:44:36 andrei Exp $ */
/*
TODO:
@@ -560,7 +560,12 @@
in instead of the backref */
match = subject + offsets[backref<<1];
match_len = offsets[(backref<<1)+1] - offsets[backref<<1];
- esc_match = php_addslashes(match, match_len, &esc_match_len, 0);
+ if (match_len)
+ esc_match = php_addslashes(match, match_len, &esc_match_len, 0);
+ else {
+ esc_match = match;
+ esc_match_len = 0;
+ }
sprintf(backref_buf, "\\%d", backref);
new_code = php_str_to_str(code, code_len,
backref_buf, (backref > 9) ? 3 : 2,
@@ -570,7 +575,8 @@
walk = new_code + (walk - code) + match_len;
/* Clean up and reassign */
- efree(esc_match);
+ if (esc_match_len)
+ efree(esc_match);
efree(code);
code = new_code;
code_len = new_code_len;