From d3b74b0ec5687da2f2259a3a79f7fb18de294a92 Mon Sep 17 00:00:00 2001 From: foobar Date: Sat, 11 Jun 2005 20:21:50 +0000 Subject: [PATCH] regenerated with re2c 0.9.7 --- ext/standard/url_scanner_ex.c | 176 ++++++++++--------- ext/standard/var_unserializer.c | 292 ++++++++++++++++++-------------- 2 files changed, 250 insertions(+), 218 deletions(-) diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 8724622ff6..1e08dfae0f 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -1,15 +1,15 @@ -/* Generated by re2c 0.9.6 on Fri Apr 15 01:41:19 2005 */ -#line 1 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +/* Generated by re2c 0.9.7 on Sat Jun 11 22:56:09 2005 */ +#line 1 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ - | PHP Version 4 | + | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | + | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | + | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -91,7 +91,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=,fieldset=", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals) PHP_INI_END() -#line 97 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 97 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" #define YYFILL(n) goto done @@ -109,11 +109,6 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st q = (p = url->c) + url->len; scan: - -#line 7 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, @@ -148,6 +143,10 @@ scan: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; + +#line 148 "" +{ + YYCTYPE yych; goto yy0; ++YYCURSOR; yy0: @@ -162,21 +161,21 @@ yy0: yy2: ++YYCURSOR; goto yy3; yy3: -#line 115 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 115 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { smart_str_append(dest, url); return; } -#line 61 "" +#line 167 "" yy4: ++YYCURSOR; goto yy5; yy5: -#line 116 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 116 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { sep = separator; goto scan; } -#line 67 "" +#line 173 "" yy6: ++YYCURSOR; goto yy7; yy7: -#line 117 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 117 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { bash = p - 1; goto done; } -#line 73 "" +#line 179 "" yy8: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -186,11 +185,11 @@ yy9: if(yybm[0+yych] & 128) { } goto yy10; yy10: -#line 118 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 118 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { goto scan; } -#line 86 "" +#line 191 "" } -#line 119 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 119 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" done: @@ -358,11 +357,6 @@ state_plain_begin: state_plain: start = YYCURSOR; - -#line 90 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, @@ -397,6 +391,10 @@ state_plain: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; + +#line 396 "" +{ + YYCTYPE yych; goto yy11; ++YYCURSOR; yy11: @@ -409,9 +407,9 @@ yy11: yy13: ++YYCURSOR; goto yy14; yy14: -#line 287 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 287 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; } -#line 142 "" +#line 413 "" yy15: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -421,20 +419,15 @@ yy16: if(yybm[0+yych] & 128) { } goto yy17; yy17: -#line 288 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 288 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_plain; } -#line 155 "" +#line 425 "" } -#line 289 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 289 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" state_tag: start = YYCURSOR; - -#line 159 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -469,6 +462,10 @@ state_tag: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +#line 467 "" +{ + YYCTYPE yych; goto yy18; ++YYCURSOR; yy18: @@ -483,15 +480,15 @@ yy20: ++YYCURSOR; yych = *YYCURSOR; goto yy25; yy21: -#line 294 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 294 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; } -#line 212 "" +#line 486 "" yy22: ++YYCURSOR; goto yy23; yy23: -#line 295 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 295 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_plain_begin; } -#line 218 "" +#line 492 "" yy24: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -501,7 +498,7 @@ yy25: if(yybm[0+yych] & 128) { } goto yy21; } -#line 296 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 296 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" state_next_arg_begin: @@ -509,11 +506,6 @@ state_next_arg_begin: state_next_arg: start = YYCURSOR; - -#line 231 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 0, 0, 0, 0, @@ -548,6 +540,10 @@ state_next_arg: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +#line 545 "" +{ + YYCTYPE yych; goto yy26; ++YYCURSOR; yy26: @@ -575,28 +571,28 @@ yy26: yy28: ++YYCURSOR; goto yy29; yy29: -#line 304 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 304 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; } -#line 298 "" +#line 577 "" yy30: ++YYCURSOR; yych = *YYCURSOR; goto yy37; yy31: -#line 305 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 305 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_next_arg; } -#line 304 "" +#line 584 "" yy32: ++YYCURSOR; goto yy33; yy33: -#line 306 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 306 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { --YYCURSOR; STATE = STATE_ARG; goto state_arg; } -#line 310 "" +#line 590 "" yy34: ++YYCURSOR; goto yy35; yy35: -#line 307 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 307 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_plain_begin; } -#line 316 "" +#line 596 "" yy36: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -606,16 +602,11 @@ yy37: if(yybm[0+yych] & 128) { } goto yy31; } -#line 308 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 308 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" state_arg: start = YYCURSOR; - -#line 329 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -650,6 +641,10 @@ state_arg: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +#line 646 "" +{ + YYCTYPE yych; goto yy38; ++YYCURSOR; yy38: @@ -664,15 +659,15 @@ yy40: ++YYCURSOR; yych = *YYCURSOR; goto yy45; yy41: -#line 313 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 313 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; } -#line 382 "" +#line 665 "" yy42: ++YYCURSOR; goto yy43; yy43: -#line 314 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 314 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; } -#line 388 "" +#line 671 "" yy44: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -682,16 +677,11 @@ yy45: if(yybm[0+yych] & 128) { } goto yy41; } -#line 315 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 315 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" state_before_val: start = YYCURSOR; - -#line 401 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -726,6 +716,11 @@ state_before_val: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +#line 721 "" +{ + YYCTYPE yych; + unsigned int yyaccept; goto yy46; ++YYCURSOR; yy46: @@ -740,16 +735,16 @@ yy48: yyaccept = 0; if(yych == '=') goto yy53; goto yy49; yy49: -#line 321 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 321 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { --YYCURSOR; goto state_next_arg_begin; } -#line 455 "" +#line 741 "" yy50: ++YYCURSOR; yych = *YYCURSOR; goto yy54; yy51: -#line 320 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 320 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; } -#line 461 "" +#line 748 "" yy52: yych = *++YYCURSOR; goto yy49; yy53: ++YYCURSOR; @@ -772,17 +767,12 @@ yy57: YYCURSOR = YYMARKER; case 0: goto yy49; } } -#line 322 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 322 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" state_val: start = YYCURSOR; - -#line 488 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 248, 248, 248, 248, 248, 248, 248, 248, 248, 160, 160, 248, 248, 248, 248, 248, @@ -817,6 +807,11 @@ state_val: 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, }; + +#line 812 "" +{ + YYCTYPE yych; + unsigned int yyaccept; goto yy58; ++YYCURSOR; yy58: @@ -844,9 +839,9 @@ yy60: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy77; yy61: -#line 330 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 330 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 0, '\0'); goto state_next_arg_begin; } -#line 555 "" +#line 845 "" yy62: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy69; @@ -855,9 +850,9 @@ yy63: yych = *++YYCURSOR; yy64: ++YYCURSOR; goto yy65; yy65: -#line 331 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 331 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_next_arg_begin; } -#line 566 "" +#line 856 "" yy66: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -884,9 +879,9 @@ yy70: ++YYCURSOR; } goto yy71; yy71: -#line 329 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 329 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; } -#line 595 "" +#line 885 "" yy72: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -920,9 +915,9 @@ yy78: ++YYCURSOR; } goto yy79; yy79: -#line 328 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 328 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; } -#line 631 "" +#line 921 "" yy80: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -936,7 +931,7 @@ yy82: ++YYCURSOR; yych = *YYCURSOR; goto yy79; } -#line 332 "/usr/src/php/php_4_3/ext/standard/url_scanner_ex.re" +#line 332 "/usr/src/php/php5/ext/standard/url_scanner_ex.re" stop: @@ -1115,6 +1110,7 @@ PHP_MINIT_FUNCTION(url_scanner) PHP_MSHUTDOWN_FUNCTION(url_scanner) { UNREGISTER_INI_ENTRIES(); + return SUCCESS; } diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index f6a1072e63..fa4905abe3 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,21 +1,21 @@ -/* Generated by re2c 0.9.6 on Fri Apr 15 01:41:08 2005 */ -#line 1 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +/* Generated by re2c 0.9.7 on Sat Jun 11 22:56:18 2005 */ +#line 1 "/usr/src/php/php5/ext/standard/var_unserializer.re" /* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Sascha Schumann | + +----------------------------------------------------------------------+ */ /* $Id$ */ @@ -89,7 +89,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **n for (i = 0; i < var_hash->used_slots; i++) { if (var_hash->data[i] == ozval) { var_hash->data[i] = *nzval; - return; + /* do not break here */ } } var_hash = var_hash->next; @@ -125,7 +125,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) efree(var_hash); var_hash = next; } - + var_hash = var_hashx->first_dtor; while (var_hash) { @@ -147,7 +147,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) #define YYMARKER marker -#line 154 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 155 "/usr/src/php/php5/ext/standard/var_unserializer.re" @@ -277,10 +277,37 @@ static inline int finish_nested_data(UNSERIALIZE_PARAMETER) return 0; } -static inline int object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) +static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { - long elements; + long datalen; + + if(ce->unserialize == NULL) { + zend_error(E_WARNING, "Class %s has no unserializer", ce->name); + return 0; + } + datalen = parse_iv2((*p) + 2, p); + + (*p) += 2; + + if(datalen < 0 || (*p) + datalen >= max) { + zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %d present", datalen, max - (*p)); + return 0; + } + + if(ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { + return 0; + } + + (*p) += datalen; + + return finish_nested_data(UNSERIALIZE_PASSTHRU); +} + +static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) +{ + long elements; + elements = parse_iv2((*p) + 2, p); (*p) += 2; @@ -298,9 +325,12 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) return 0; } - INIT_PZVAL(&fname); - ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0); - call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); + if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY && + zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) { + INIT_PZVAL(&fname); + ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0); + call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); + } if (retval_ptr) zval_ptr_dtor(&retval_ptr); @@ -309,20 +339,6 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) } -static char *str_tolower_copy(char *dest, const char *source, unsigned int length) -{ - register unsigned char *str = (unsigned char*)source; - register unsigned char *result = (unsigned char*)dest; - register unsigned char *end = str + length; - - while (str < end) { - *result++ = tolower((int)*str++); - } - *result = *end; - - return dest; -} - PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) { const unsigned char *cursor, *limit, *marker, *start; @@ -338,11 +354,6 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) - -#line 7 "" -{ - YYCTYPE yych; - unsigned int yyaccept; static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -377,34 +388,40 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +#line 393 "" +{ + YYCTYPE yych; + unsigned int yyaccept; goto yy0; ++YYCURSOR; yy0: if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; - if(yych <= 'd'){ - if(yych <= 'R'){ - if(yych <= 'N'){ - if(yych <= 'M') goto yy16; - goto yy6; + if(yych <= 'c'){ + if(yych <= 'O'){ + if(yych <= 'C'){ + if(yych <= 'B') goto yy16; + goto yy13; } else { - if(yych <= 'O') goto yy13; - if(yych <= 'Q') goto yy16; - goto yy3; + if(yych <= 'M') goto yy16; + if(yych <= 'N') goto yy6; + goto yy13; } } else { - if(yych <= 'a'){ - if(yych <= '`') goto yy16; - goto yy11; + if(yych <= '`'){ + if(yych == 'R') goto yy3; + goto yy16; } else { + if(yych <= 'a') goto yy11; if(yych <= 'b') goto yy7; - if(yych <= 'c') goto yy16; - goto yy9; + goto yy16; } } } else { if(yych <= 'q'){ if(yych <= 'i'){ + if(yych <= 'd') goto yy9; if(yych <= 'h') goto yy16; goto yy8; } else { @@ -432,9 +449,9 @@ yy3: yyaccept = 0; if(yych == ':') goto yy87; goto yy4; yy4: -#line 590 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 626 "/usr/src/php/php5/ext/standard/var_unserializer.re" { return 0; } -#line 102 "" +#line 455 "" yy5: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if(yych == ':') goto yy81; @@ -473,13 +490,13 @@ yy13: yyaccept = 0; yy14: ++YYCURSOR; goto yy15; yy15: -#line 584 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 620 "/usr/src/php/php5/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"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 147 "" +#line 500 "" yy16: yych = *++YYCURSOR; goto yy4; yy17: yych = *++YYCURSOR; @@ -508,18 +525,25 @@ yy21: yych = *++YYCURSOR; yy22: ++YYCURSOR; goto yy23; yy23: -#line 495 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 508 "/usr/src/php/php5/ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; char *class_name; zend_class_entry *ce; + zend_class_entry **pce; int incomplete_class = 0; - + + int custom_object = 0; + zval *user_func; zval *retval_ptr; zval **args[1]; zval *arg_func_name; + + if(*start == 'C') { + custom_object = 1; + } INIT_PZVAL(*rval); len2 = len = parse_uiv(start + 2); @@ -541,63 +565,79 @@ yy23: *p = YYCURSOR+1; return 0; } - - class_name = str_tolower_copy((char *)emalloc(len+1), class_name, len); - class_name[len] = '\0'; - - len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyz"); + + len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"); if (len3 != len) { *p = YYCURSOR + len3 - len; - efree(class_name); return 0; } - if (zend_hash_find(CG(class_table), class_name, len + 1, (void **) &ce) != SUCCESS) { + class_name = estrndup(class_name, len); + + do { + /* Try to find class directly */ + if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { + ce = *pce; + break; + } + + /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; + break; + } + + /* Call unserialize callback */ + MAKE_STD_ZVAL(user_func); + ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); + args[0] = &arg_func_name; + MAKE_STD_ZVAL(arg_func_name); + ZVAL_STRING(arg_func_name, class_name, 1); + if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); + incomplete_class = 1; + ce = PHP_IC_ENTRY; + zval_ptr_dtor(&user_func); + zval_ptr_dtor(&arg_func_name); + break; + } + if (retval_ptr) { + zval_ptr_dtor(&retval_ptr); + } + + /* The callback function may have defined the class */ + if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { + ce = *pce; } else { - MAKE_STD_ZVAL(user_func); - ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); - - args[0] = &arg_func_name; - MAKE_STD_ZVAL(arg_func_name); - ZVAL_STRING(arg_func_name, class_name, 1); - - if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { - zend_error(E_WARNING, "'unserialize_callback_func' defined (%s) but not found", user_func->value.str.val); - incomplete_class = 1; - ce = PHP_IC_ENTRY; - } else { - if (zend_hash_find(CG(class_table), class_name, len + 1, (void **) &ce) != SUCCESS) { - zend_error(E_WARNING, "'unserialize_callback_func' (%s) hasn't defined the class it was called for", user_func->value.str.val); - incomplete_class = 1; - ce = PHP_IC_ENTRY; - } else { -#ifdef ZEND_ENGINE_2 - ce = *(zend_class_entry **)ce; /* Bad hack, TBF! */ -#endif - } - } + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val); + incomplete_class = 1; + ce = PHP_IC_ENTRY; } - } else { -#ifdef ZEND_ENGINE_2 - ce = *(zend_class_entry **)ce; /* Bad hack, TBF! */ -#endif - } + + zval_ptr_dtor(&user_func); + zval_ptr_dtor(&arg_func_name); + break; + } while (1); *p = YYCURSOR; + + if(custom_object) { + efree(class_name); + return object_custom(UNSERIALIZE_PASSTHRU, ce); + } + elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { - php_store_class_name(*rval, class_name, len2 TSRMLS_CC); + php_store_class_name(*rval, class_name, len2); } efree(class_name); return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 266 "" +#line 641 "" yy24: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -626,7 +666,7 @@ yy28: yych = *++YYCURSOR; yy29: ++YYCURSOR; goto yy30; yy30: -#line 487 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 500 "/usr/src/php/php5/ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -634,7 +674,7 @@ yy30: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 304 "" +#line 678 "" yy31: yych = *++YYCURSOR; if(yych == '+') goto yy32; if(yych <= '/') goto yy2; @@ -658,7 +698,7 @@ yy35: yych = *++YYCURSOR; yy36: ++YYCURSOR; goto yy37; yy37: -#line 461 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 478 "/usr/src/php/php5/ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -668,10 +708,6 @@ yy37: return 0; } - if (elements < 0) { - return 0; - } - INIT_PZVAL(*rval); Z_TYPE_PP(rval) = IS_ARRAY; ALLOC_HASHTABLE(Z_ARRVAL_PP(rval)); @@ -684,7 +720,7 @@ yy37: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 355 "" +#line 724 "" yy38: yych = *++YYCURSOR; if(yych == '+') goto yy39; if(yych <= '/') goto yy2; @@ -708,7 +744,7 @@ yy42: yych = *++YYCURSOR; yy43: ++YYCURSOR; goto yy44; yy44: -#line 433 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 450 "/usr/src/php/php5/ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -736,7 +772,7 @@ yy44: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 408 "" +#line 776 "" yy45: yych = *++YYCURSOR; if(yych <= '/'){ if(yych <= ','){ @@ -825,14 +861,14 @@ yy54: if(yych <= ';'){ yy55: ++YYCURSOR; goto yy56; yy56: -#line 426 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 443 "/usr/src/php/php5/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 506 "" +#line 872 "" yy57: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -892,7 +928,7 @@ yy65: yych = *++YYCURSOR; yy66: ++YYCURSOR; goto yy67; yy67: -#line 411 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 428 "/usr/src/php/php5/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -907,7 +943,7 @@ yy67: return 1; } -#line 583 "" +#line 947 "" yy68: yych = *++YYCURSOR; if(yych == 'N') goto yy65; goto yy2; @@ -936,14 +972,14 @@ yy72: if(yych <= '/') goto yy2; yy73: ++YYCURSOR; goto yy74; yy74: -#line 404 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 421 "/usr/src/php/php5/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 620 "" +#line 983 "" yy75: yych = *++YYCURSOR; if(yych <= '/') goto yy2; if(yych >= '2') goto yy2; @@ -954,25 +990,25 @@ yy76: yych = *++YYCURSOR; yy77: ++YYCURSOR; goto yy78; yy78: -#line 397 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 414 "/usr/src/php/php5/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 638 "" +#line 1001 "" yy79: ++YYCURSOR; goto yy80; yy80: -#line 390 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 407 "/usr/src/php/php5/ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 649 "" +#line 1012 "" yy81: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -998,7 +1034,7 @@ yy84: if(yych <= '/') goto yy2; yy85: ++YYCURSOR; goto yy86; yy86: -#line 367 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 384 "/usr/src/php/php5/ext/standard/var_unserializer.re" { long id; @@ -1009,19 +1045,19 @@ yy86: if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) { return 0; } - + if (*rval == *rval_ref) return 0; if (*rval != NULL) { - zval_ptr_dtor(rval); + zval_ptr_dtor(rval); } *rval = *rval_ref; (*rval)->refcount++; - (*rval)->is_ref = 1; + (*rval)->is_ref = 0; return 1; } -#line 699 "" +#line 1061 "" yy87: yych = *++YYCURSOR; if(yych <= ','){ if(yych != '+') goto yy2; @@ -1047,7 +1083,7 @@ yy90: if(yych <= '/') goto yy2; yy91: ++YYCURSOR; goto yy92; yy92: -#line 346 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 363 "/usr/src/php/php5/ext/standard/var_unserializer.re" { long id; @@ -1060,7 +1096,7 @@ yy92: } if (*rval != NULL) { - zval_ptr_dtor(rval); + zval_ptr_dtor(rval); } *rval = *rval_ref; (*rval)->refcount++; @@ -1068,9 +1104,9 @@ yy92: return 1; } -#line 747 "" +#line 1108 "" } -#line 592 "/usr/src/php/php_4_3/ext/standard/var_unserializer.re" +#line 628 "/usr/src/php/php5/ext/standard/var_unserializer.re" return 0; -- 2.40.0