It doesn't do it in HEAD? :)
(I really don't care if you forget to MFB, it wouldn't be
the first commit lately.. :)
--Jani
On Mon, 26 Sep 2005, Ilia Alshanetsky wrote:
iliaa Mon Sep 26 11:14:19 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/ctype/tests bug34645.phpt
Modified files:
/php-src/ext/ctype ctype.c
Log:
Fixed bug #34645 (ctype corrupts memory when validating large numbers).
http://cvs.php.net/diff.php/php-src/ext/ctype/ctype.c?r1=1.34&r2=1.34.2.1&ty=u
Index: php-src/ext/ctype/ctype.c
diff -u php-src/ext/ctype/ctype.c:1.34 php-src/ext/ctype/ctype.c:1.34.2.1
--- php-src/ext/ctype/ctype.c:1.34 Wed Aug 3 10:06:43 2005
+++ php-src/ext/ctype/ctype.c Mon Sep 26 11:14:19 2005
@@ -92,34 +92,39 @@
/* {{{ ctype
*/
#define CTYPE(iswhat) \
- zval *c; \
+ zval *c, tmp; \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &c) ==
FAILURE) \
return; \
- switch (Z_TYPE_P(c)) { \
- case IS_LONG: \
+ if (Z_TYPE_P(c) == IS_LONG) { \
if (Z_LVAL_P(c) <= 255 && Z_LVAL_P(c) >= 0) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c))); \
} else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \
} \
- SEPARATE_ZVAL(&c); \
- convert_to_string(c); \
- case IS_STRING: \
- { \
- char *p = Z_STRVAL_P(c), *e = Z_STRVAL_P(c) +
Z_STRLEN_P(c); \
- if (e == p) { \
- RETURN_FALSE; \
- } \
- while (p < e) { \
- if(!iswhat((int)*(unsigned char *)(p++)))
RETURN_FALSE; \
+ tmp = *c; \
+ zval_copy_ctor(&tmp); \
+ convert_to_string(&tmp); \
+ } else { \
+ tmp = *c; \
+ } \
+ if (Z_TYPE(tmp) == IS_STRING) { \
+ char *p = Z_STRVAL(tmp), *e = Z_STRVAL(tmp) + Z_STRLEN(tmp); \
+ if (e == p) { \
+ if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
+ RETURN_FALSE; \
+ } \
+ while (p < e) { \
+ if(!iswhat((int)*(unsigned char *)(p++))) { \
+ if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
+ RETURN_FALSE; \
} \
- RETURN_TRUE; \
} \
- default: \
- break; \
+ if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
+ RETURN_TRUE; \
+ } else { \
+ RETURN_FALSE; \
} \
- RETURN_FALSE;
-
+
/* }}} */
/* {{{ proto bool ctype_alnum(mixed c)
http://cvs.php.net/co.php/php-src/ext/ctype/tests/bug34645.phpt?r=1.1&p=1
Index: php-src/ext/ctype/tests/bug34645.phpt
+++ php-src/ext/ctype/tests/bug34645.phpt
--
Donate @ <http://pecl.php.net/wishlist.php/sniper>
Disclaimer: Donating money may make me happier and friendlier for a limited
period!
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php