From: Ilia Alshanetsky Date: Sun, 30 Jan 2005 16:39:55 +0000 (+0000) Subject: MFH: Fix handling of INF/NAN in unserialize(). X-Git-Tag: php-4.3.11RC1~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1afbc301f119f4105dae92d43b3591f10d8e95b9;p=php MFH: Fix handling of INF/NAN in unserialize(). --- diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 1bce2233b9..a15120e9fe 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.3 on Wed Jan 26 11:07:03 2005 */ +/* Generated by re2c 0.9.3 on Sun Jan 30 11:35:55 2005 */ #line 1 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -432,7 +432,7 @@ yy3: yyaccept = 0; if(yych == ':') goto yy87; goto yy4; yy4: -#line 576 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 574 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { return 0; } #line 102 "" yy5: yyaccept = 0; @@ -473,7 +473,7 @@ yy13: yyaccept = 0; yy14: ++YYCURSOR; goto yy15; yy15: -#line 570 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 568 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); @@ -502,7 +502,7 @@ yy21: yych = *++YYCURSOR; yy22: ++YYCURSOR; goto yy23; yy23: -#line 489 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 487 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { size_t len, len2, maxlen; int elements; @@ -612,7 +612,7 @@ yy28: yych = *++YYCURSOR; yy29: ++YYCURSOR; goto yy30; yy30: -#line 481 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 479 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -644,7 +644,7 @@ yy35: yych = *++YYCURSOR; yy36: ++YYCURSOR; goto yy37; yy37: -#line 463 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 461 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { int elements = parse_iv(start + 2); @@ -686,7 +686,7 @@ yy42: yych = *++YYCURSOR; yy43: ++YYCURSOR; goto yy44; yy44: -#line 435 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 433 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -803,7 +803,7 @@ yy54: if(yych <= ';'){ yy55: ++YYCURSOR; goto yy56; yy56: -#line 428 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 426 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -874,9 +874,7 @@ yy67: { *p = YYCURSOR; INIT_PZVAL(*rval); -#if defined(HAVE_ATOF_ACCEPTS_NAN) && defined(HAVE_ATOF_ACCEPTS_INF) - ZVAL_DOUBLE(*rval, zend_strtod(start + 2, NULL)); -#else + if (!strncmp(start + 2, "NAN", 3)) { ZVAL_DOUBLE(*rval, php_get_nan()); } else if (!strncmp(start + 2, "INF", 3)) { @@ -884,10 +882,10 @@ yy67: } else if (!strncmp(start + 2, "-INF", 4)) { ZVAL_DOUBLE(*rval, -php_get_inf()); } -#endif + return 1; } -#line 563 "" +#line 561 "" yy68: yych = *++YYCURSOR; if(yych == 'N') goto yy65; goto yy2; @@ -923,7 +921,7 @@ yy74: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 600 "" +#line 598 "" yy75: yych = *++YYCURSOR; if(yych <= '/') goto yy2; if(yych >= '2') goto yy2; @@ -941,7 +939,7 @@ yy78: ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 618 "" +#line 616 "" yy79: ++YYCURSOR; goto yy80; yy80: @@ -952,7 +950,7 @@ yy80: ZVAL_NULL(*rval); return 1; } -#line 629 "" +#line 627 "" yy81: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -1001,7 +999,7 @@ yy86: return 1; } -#line 679 "" +#line 677 "" yy87: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -1048,9 +1046,9 @@ yy92: return 1; } -#line 727 "" +#line 725 "" } -#line 578 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" +#line 576 "/home/rei/php_dev/php4/ext/standard/var_unserializer.re" return 0; diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 7442f76fc7..4b3e36dbf3 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -411,9 +411,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) "d:" ("NAN" | "-"? "INF") ";" { *p = YYCURSOR; INIT_PZVAL(*rval); -#if defined(HAVE_ATOF_ACCEPTS_NAN) && defined(HAVE_ATOF_ACCEPTS_INF) - ZVAL_DOUBLE(*rval, zend_strtod(start + 2, NULL)); -#else + if (!strncmp(start + 2, "NAN", 3)) { ZVAL_DOUBLE(*rval, php_get_nan()); } else if (!strncmp(start + 2, "INF", 3)) { @@ -421,7 +419,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } else if (!strncmp(start + 2, "-INF", 4)) { ZVAL_DOUBLE(*rval, -php_get_inf()); } -#endif + return 1; }