fix bug #27120 and bug #25975 - preserve is_ref when bound

objects are serialized
This commit is contained in:
Stanislav Malyshev 2004-02-03 14:12:59 +00:00
parent 8013d5fa39
commit 3fd027c5ac
3 changed files with 232 additions and 160 deletions

View File

@ -549,11 +549,16 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va
HashTable *myht;
if(var_hash
&& php_add_var_hash(var_hash, *struc, (void *) &var_already) == FAILURE
&& ((*struc)->is_ref || Z_TYPE_PP(struc) == IS_OBJECT)) {
smart_str_appendl(buf, "R:", 2);
smart_str_append_long(buf, *var_already);
smart_str_appendc(buf, ';');
&& php_add_var_hash(var_hash, *struc, (void *) &var_already) == FAILURE) {
if((*struc)->is_ref) {
smart_str_appendl(buf, "R:", 2);
smart_str_append_long(buf, *var_already);
smart_str_appendc(buf, ';');
} else if(Z_TYPE_PP(struc) == IS_OBJECT) {
smart_str_appendl(buf, "r:", 2);
smart_str_append_long(buf, *var_already);
smart_str_appendc(buf, ';');
}
return;
}

View File

@ -1,5 +1,5 @@
/* Generated by re2c 0.5 on Thu Jan 8 20:25:56 2004 */
#line 1 "/usr/src/web/php/php5/ext/standard/var_unserializer.re"
/* Generated by re2c 0.5 on Tue Feb 3 16:01:43 2004 */
#line 1 "var_unserializer.re"
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
@ -297,39 +297,40 @@ yy0:
if(yych <= 'd'){
if(yych <= 'R'){
if(yych <= 'N'){
if(yych <= 'M') goto yy15;
goto yy5;
if(yych <= 'M') goto yy16;
goto yy6;
} else {
if(yych <= 'O') goto yy12;
if(yych <= 'Q') goto yy15;
if(yych <= 'O') goto yy13;
if(yych <= 'Q') goto yy16;
goto yy3;
}
} else {
if(yych <= 'a'){
if(yych <= '`') goto yy15;
goto yy10;
if(yych <= '`') goto yy16;
goto yy11;
} else {
if(yych <= 'b') goto yy6;
if(yych <= 'c') goto yy15;
goto yy8;
if(yych <= 'b') goto yy7;
if(yych <= 'c') goto yy16;
goto yy9;
}
}
} else {
if(yych <= 'r'){
if(yych <= 'q'){
if(yych <= 'i'){
if(yych <= 'h') goto yy15;
goto yy7;
if(yych <= 'h') goto yy16;
goto yy8;
} else {
if(yych == 'o') goto yy11;
goto yy15;
if(yych == 'o') goto yy12;
goto yy16;
}
} else {
if(yych <= '|'){
if(yych <= 's') goto yy9;
goto yy15;
if(yych <= 'r') goto yy5;
if(yych <= 's') goto yy10;
goto yy16;
} else {
if(yych <= '}') goto yy13;
if(yych <= '\277') goto yy15;
if(yych <= '}') goto yy14;
if(yych <= '\277') goto yy16;
}
}
}
@ -339,67 +340,71 @@ yy2: YYCURSOR = YYMARKER;
}
yy3: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy74;
if(yych == ':') goto yy81;
yy4:
#line 440
#line 461
{ return 0; }
yy5: yych = *++YYCURSOR;
if(yych == ';') goto yy72;
goto yy4;
yy6: yyaccept = 0;
yy5: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy66;
if(yych == ':') goto yy75;
goto yy4;
yy6: yych = *++YYCURSOR;
if(yych == ';') goto yy73;
goto yy4;
yy7: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy60;
if(yych == ':') goto yy67;
goto yy4;
yy8: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy44;
if(yych == ':') goto yy61;
goto yy4;
yy9: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy37;
if(yych == ':') goto yy45;
goto yy4;
yy10: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy30;
if(yych == ':') goto yy38;
goto yy4;
yy11: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy23;
if(yych == ':') goto yy31;
goto yy4;
yy12: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy16;
if(yych == ':') goto yy24;
goto yy4;
yy13: yych = *++YYCURSOR;
yy14:
#line 434
yy13: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy17;
goto yy4;
yy14: yych = *++YYCURSOR;
yy15:
#line 455
{
/* 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? */
}
yy15: yych = *++YYCURSOR;
goto yy4;
yy16: yych = *++YYCURSOR;
if(yybm[0+yych] & 128) goto yy18;
if(yych != '+') goto yy2;
goto yy4;
yy17: yych = *++YYCURSOR;
if(yybm[0+yych] & 128) goto yy18;
if(yybm[0+yych] & 128) goto yy19;
if(yych != '+') goto yy2;
yy18: yych = *++YYCURSOR;
if(yybm[0+yych] & 128) goto yy19;
goto yy2;
yy18: ++YYCURSOR;
yy19: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy19: if(yybm[0+yych] & 128) goto yy18;
yy20: if(yybm[0+yych] & 128) goto yy19;
if(yych != ':') goto yy2;
yy20: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
yy21: yych = *++YYCURSOR;
yy22:
#line 355
if(yych != '"') goto yy2;
yy22: yych = *++YYCURSOR;
yy23:
#line 376
{
int len;
int elements;
@ -478,29 +483,29 @@ yy22:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
yy23: yych = *++YYCURSOR;
yy24: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy24;
if(yych <= '-') goto yy25;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy25;
if(yych <= '9') goto yy26;
goto yy2;
}
yy24: yych = *++YYCURSOR;
yy25: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy25: ++YYCURSOR;
yy26: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy26: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy25;
yy27: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy26;
if(yych >= ';') goto yy2;
yy27: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
yy28: yych = *++YYCURSOR;
yy29:
#line 347
if(yych != '"') goto yy2;
yy29: yych = *++YYCURSOR;
yy30:
#line 368
{
INIT_PZVAL(*rval);
@ -508,25 +513,25 @@ yy29:
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
}
yy30: yych = *++YYCURSOR;
if(yych == '+') goto yy31;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy32;
goto yy2;
yy31: yych = *++YYCURSOR;
if(yych == '+') goto yy32;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy33;
goto yy2;
yy32: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy32: ++YYCURSOR;
yy33: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy33: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy32;
yy34: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy33;
if(yych >= ';') goto yy2;
yy34: yych = *++YYCURSOR;
if(yych != '{') goto yy2;
yy35: yych = *++YYCURSOR;
yy36:
#line 329
if(yych != '{') goto yy2;
yy36: yych = *++YYCURSOR;
yy37:
#line 350
{
int elements = parse_iv(start + 2);
@ -544,25 +549,25 @@ yy36:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
yy37: yych = *++YYCURSOR;
if(yych == '+') goto yy38;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy39;
goto yy2;
yy38: yych = *++YYCURSOR;
if(yych == '+') goto yy39;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy40;
goto yy2;
yy39: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy39: ++YYCURSOR;
yy40: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy40: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy39;
yy41: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy40;
if(yych >= ';') goto yy2;
yy41: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
yy42: yych = *++YYCURSOR;
yy43:
#line 309
if(yych != '"') goto yy2;
yy43: yych = *++YYCURSOR;
yy44:
#line 330
{
int len;
char *str;
@ -582,199 +587,240 @@ yy43:
ZVAL_STRINGL(*rval, str, len, 0);
return 1;
}
yy44: yych = *++YYCURSOR;
yy45: yych = *++YYCURSOR;
if(yych <= '-'){
if(yych == '+') goto yy45;
if(yych == '+') goto yy46;
if(yych <= ',') goto yy2;
} else {
if(yych <= '.') goto yy48;
if(yych <= '.') goto yy49;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy46;
if(yych <= '9') goto yy47;
goto yy2;
}
yy45: yych = *++YYCURSOR;
if(yych == '.') goto yy48;
yy46: yych = *++YYCURSOR;
if(yych == '.') goto yy49;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy46: ++YYCURSOR;
yy47: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy47: if(yych <= ':'){
yy48: if(yych <= ':'){
if(yych <= '.'){
if(yych <= '-') goto yy2;
goto yy58;
goto yy59;
} else {
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy46;
if(yych <= '9') goto yy47;
goto yy2;
}
} else {
if(yych <= 'E'){
if(yych <= ';') goto yy51;
if(yych <= ';') goto yy52;
if(yych <= 'D') goto yy2;
goto yy53;
goto yy54;
} else {
if(yych == 'e') goto yy53;
if(yych == 'e') goto yy54;
goto yy2;
}
}
yy48: yych = *++YYCURSOR;
yy49: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy49: ++YYCURSOR;
yy50: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy50: if(yych <= ';'){
yy51: if(yych <= ';'){
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy49;
if(yych <= '9') goto yy50;
if(yych <= ':') goto yy2;
} else {
if(yych <= 'E'){
if(yych <= 'D') goto yy2;
goto yy53;
goto yy54;
} else {
if(yych == 'e') goto yy53;
if(yych == 'e') goto yy54;
goto yy2;
}
}
yy51: yych = *++YYCURSOR;
yy52:
#line 302
yy52: yych = *++YYCURSOR;
yy53:
#line 323
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_DOUBLE(*rval, atof(start + 2));
return 1;
}
yy53: yych = *++YYCURSOR;
yy54: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy54;
if(yych <= '-') goto yy55;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy55;
if(yych <= '9') goto yy56;
goto yy2;
}
yy54: yych = *++YYCURSOR;
yy55: yych = *++YYCURSOR;
if(yych <= ','){
if(yych == '+') goto yy57;
if(yych == '+') goto yy58;
goto yy2;
} else {
if(yych <= '-') goto yy57;
if(yych <= '-') goto yy58;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
}
yy55: ++YYCURSOR;
yy56: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy56: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy55;
if(yych == ';') goto yy51;
yy57: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy56;
if(yych == ';') goto yy52;
goto yy2;
yy57: yych = *++YYCURSOR;
yy58: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy55;
if(yych <= '9') goto yy56;
goto yy2;
yy58: ++YYCURSOR;
yy59: ++YYCURSOR;
if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
yy59: if(yych <= ';'){
yy60: if(yych <= ';'){
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy58;
if(yych <= '9') goto yy59;
if(yych <= ':') goto yy2;
goto yy51;
goto yy52;
} else {
if(yych <= 'E'){
if(yych <= 'D') goto yy2;
goto yy53;
goto yy54;
} else {
if(yych == 'e') goto yy53;
if(yych == 'e') goto yy54;
goto yy2;
}
}
yy60: yych = *++YYCURSOR;
yy61: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy61;
if(yych <= '-') goto yy62;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy62;
if(yych <= '9') goto yy63;
goto yy2;
}
yy61: yych = *++YYCURSOR;
yy62: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy62: ++YYCURSOR;
yy63: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy63: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy62;
yy64: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy63;
if(yych != ';') goto yy2;
yy64: yych = *++YYCURSOR;
yy65:
#line 295
yy65: yych = *++YYCURSOR;
yy66:
#line 316
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_LONG(*rval, parse_iv(start + 2));
return 1;
}
yy66: yych = *++YYCURSOR;
yy67: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy67;
if(yych <= '-') goto yy68;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy68;
if(yych <= '9') goto yy69;
goto yy2;
}
yy67: yych = *++YYCURSOR;
yy68: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy68: ++YYCURSOR;
yy69: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy69: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy68;
yy70: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy69;
if(yych != ';') goto yy2;
yy70: yych = *++YYCURSOR;
yy71:
#line 288
yy71: yych = *++YYCURSOR;
yy72:
#line 309
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_BOOL(*rval, parse_iv(start + 2));
return 1;
}
yy72: yych = *++YYCURSOR;
yy73:
#line 281
yy73: yych = *++YYCURSOR;
yy74:
#line 302
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_NULL(*rval);
return 1;
}
yy74: yych = *++YYCURSOR;
yy75: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy75;
if(yych <= '-') goto yy76;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy76;
if(yych <= '9') goto yy77;
goto yy2;
}
yy75: yych = *++YYCURSOR;
yy76: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy76: ++YYCURSOR;
yy77: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy77: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy76;
yy78: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy77;
if(yych != ';') goto yy2;
yy78: yych = *++YYCURSOR;
yy79:
yy79: yych = *++YYCURSOR;
yy80:
#line 281
{
int id;
*p = YYCURSOR;
if (!var_hash) return 0;
id = parse_iv(start + 2) - 1;
if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) {
return 0;
}
if (*rval != NULL) {
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
(*rval)->refcount++;
(*rval)->is_ref = 0;
return 1;
}
yy81: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
} else {
if(yych <= '-') goto yy82;
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy83;
goto yy2;
}
yy82: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= ':') goto yy2;
yy83: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy84: if(yych <= '/') goto yy2;
if(yych <= '9') goto yy83;
if(yych != ';') goto yy2;
yy85: yych = *++YYCURSOR;
yy86:
#line 260
{
int id;
@ -797,7 +843,7 @@ yy79:
return 1;
}
}
#line 442
#line 463
return 0;

View File

@ -278,6 +278,27 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
return 1;
}
"r:" iv ";" {
int id;
*p = YYCURSOR;
if (!var_hash) return 0;
id = parse_iv(start + 2) - 1;
if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) {
return 0;
}
if (*rval != NULL) {
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
(*rval)->refcount++;
(*rval)->is_ref = 0;
return 1;
}
"N;" {
*p = YYCURSOR;
INIT_PZVAL(*rval);