@@ -548,6 +548,10 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
548
548
&& zend_hash_str_exists (& Z_OBJCE_P (rval )-> function_table , "__wakeup" , sizeof ("__wakeup" )- 1 );
549
549
550
550
ht = Z_OBJPROP_P (rval );
551
+ if (elements >= HT_MAX_SIZE - zend_hash_num_elements (ht )) {
552
+ return 0 ;
553
+ }
554
+
551
555
zend_hash_extend (ht , zend_hash_num_elements (ht ) + elements , (ht -> u .flags & HASH_FLAG_PACKED ));
552
556
if (!process_nested_data (UNSERIALIZE_PASSTHRU , ht , elements , 1 )) {
553
557
if (has_wakeup ) {
@@ -617,7 +621,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
617
621
start = cursor ;
618
622
619
623
620
- #line 621 "ext/standard/var_unserializer.c"
624
+ #line 625 "ext/standard/var_unserializer.c"
621
625
{
622
626
YYCTYPE yych ;
623
627
static const unsigned char yybm [] = {
@@ -675,9 +679,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
675
679
yy2 :
676
680
++ YYCURSOR ;
677
681
yy3 :
678
- #line 998 "ext/standard/var_unserializer.re"
682
+ #line 1002 "ext/standard/var_unserializer.re"
679
683
{ return 0 ; }
680
- #line 681 "ext/standard/var_unserializer.c"
684
+ #line 685 "ext/standard/var_unserializer.c"
681
685
yy4 :
682
686
yych = * (YYMARKER = ++ YYCURSOR );
683
687
if (yych == ':' ) goto yy17 ;
@@ -724,13 +728,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
724
728
goto yy3 ;
725
729
yy15 :
726
730
++ YYCURSOR ;
727
- #line 992 "ext/standard/var_unserializer.re"
731
+ #line 996 "ext/standard/var_unserializer.re"
728
732
{
729
733
/* this is the case where we have less data than planned */
730
734
php_error_docref (NULL , E_NOTICE , "Unexpected end of serialized data" );
731
735
return 0 ; /* not sure if it should be 0 or 1 here? */
732
736
}
733
- #line 734 "ext/standard/var_unserializer.c"
737
+ #line 738 "ext/standard/var_unserializer.c"
734
738
yy17 :
735
739
yych = * ++ YYCURSOR ;
736
740
if (yybm [0 + yych ] & 128 ) {
@@ -742,13 +746,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
742
746
goto yy3 ;
743
747
yy19 :
744
748
++ YYCURSOR ;
745
- #line 676 "ext/standard/var_unserializer.re"
749
+ #line 680 "ext/standard/var_unserializer.re"
746
750
{
747
751
* p = YYCURSOR ;
748
752
ZVAL_NULL (rval );
749
753
return 1 ;
750
754
}
751
- #line 752 "ext/standard/var_unserializer.c"
755
+ #line 756 "ext/standard/var_unserializer.c"
752
756
yy21 :
753
757
yych = * ++ YYCURSOR ;
754
758
if (yych <= ',' ) {
@@ -998,7 +1002,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
998
1002
goto yy18 ;
999
1003
yy63 :
1000
1004
++ YYCURSOR ;
1001
- #line 625 "ext/standard/var_unserializer.re"
1005
+ #line 629 "ext/standard/var_unserializer.re"
1002
1006
{
1003
1007
zend_long id ;
1004
1008
@@ -1024,7 +1028,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1024
1028
1025
1029
return 1 ;
1026
1030
}
1027
- #line 1028 "ext/standard/var_unserializer.c"
1031
+ #line 1032 "ext/standard/var_unserializer.c"
1028
1032
yy65 :
1029
1033
yych = * ++ YYCURSOR ;
1030
1034
if (yych == '"' ) goto yy84 ;
@@ -1035,13 +1039,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1035
1039
goto yy18 ;
1036
1040
yy67 :
1037
1041
++ YYCURSOR ;
1038
- #line 682 "ext/standard/var_unserializer.re"
1042
+ #line 686 "ext/standard/var_unserializer.re"
1039
1043
{
1040
1044
* p = YYCURSOR ;
1041
1045
ZVAL_BOOL (rval , parse_iv (start + 2 ));
1042
1046
return 1 ;
1043
1047
}
1044
- #line 1045 "ext/standard/var_unserializer.c"
1048
+ #line 1049 "ext/standard/var_unserializer.c"
1045
1049
yy69 :
1046
1050
++ YYCURSOR ;
1047
1051
if ((YYLIMIT - YYCURSOR ) < 4 ) YYFILL (4 );
@@ -1061,7 +1065,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1061
1065
}
1062
1066
yy71 :
1063
1067
++ YYCURSOR ;
1064
- #line 730 "ext/standard/var_unserializer.re"
1068
+ #line 734 "ext/standard/var_unserializer.re"
1065
1069
{
1066
1070
#if SIZEOF_ZEND_LONG == 4
1067
1071
use_double :
@@ -1070,7 +1074,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1070
1074
ZVAL_DOUBLE (rval , zend_strtod ((const char * )start + 2 , NULL ));
1071
1075
return 1 ;
1072
1076
}
1073
- #line 1074 "ext/standard/var_unserializer.c"
1077
+ #line 1078 "ext/standard/var_unserializer.c"
1074
1078
yy73 :
1075
1079
yych = * ++ YYCURSOR ;
1076
1080
if (yych <= ',' ) {
@@ -1092,7 +1096,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1092
1096
goto yy18 ;
1093
1097
yy76 :
1094
1098
++ YYCURSOR ;
1095
- #line 688 "ext/standard/var_unserializer.re"
1099
+ #line 692 "ext/standard/var_unserializer.re"
1096
1100
{
1097
1101
#if SIZEOF_ZEND_LONG == 4
1098
1102
int digits = YYCURSOR - start - 3 ;
@@ -1118,14 +1122,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1118
1122
ZVAL_LONG (rval , parse_iv (start + 2 ));
1119
1123
return 1 ;
1120
1124
}
1121
- #line 1122 "ext/standard/var_unserializer.c"
1125
+ #line 1126 "ext/standard/var_unserializer.c"
1122
1126
yy78 :
1123
1127
yych = * ++ YYCURSOR ;
1124
1128
if (yych == '"' ) goto yy92 ;
1125
1129
goto yy18 ;
1126
1130
yy79 :
1127
1131
++ YYCURSOR ;
1128
- #line 651 "ext/standard/var_unserializer.re"
1132
+ #line 655 "ext/standard/var_unserializer.re"
1129
1133
{
1130
1134
zend_long id ;
1131
1135
@@ -1150,14 +1154,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1150
1154
1151
1155
return 1 ;
1152
1156
}
1153
- #line 1154 "ext/standard/var_unserializer.c"
1157
+ #line 1158 "ext/standard/var_unserializer.c"
1154
1158
yy81 :
1155
1159
yych = * ++ YYCURSOR ;
1156
1160
if (yych == '"' ) goto yy94 ;
1157
1161
goto yy18 ;
1158
1162
yy82 :
1159
1163
++ YYCURSOR ;
1160
- #line 840 "ext/standard/var_unserializer.re"
1164
+ #line 844 "ext/standard/var_unserializer.re"
1161
1165
{
1162
1166
size_t len , len2 , len3 , maxlen ;
1163
1167
zend_long elements ;
@@ -1309,10 +1313,10 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1309
1313
1310
1314
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1311
1315
}
1312
- #line 1313 "ext/standard/var_unserializer.c"
1316
+ #line 1317 "ext/standard/var_unserializer.c"
1313
1317
yy84 :
1314
1318
++ YYCURSOR ;
1315
- #line 771 "ext/standard/var_unserializer.re"
1319
+ #line 775 "ext/standard/var_unserializer.re"
1316
1320
{
1317
1321
size_t len , maxlen ;
1318
1322
zend_string * str ;
@@ -1346,17 +1350,17 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1346
1350
ZVAL_STR (rval , str );
1347
1351
return 1 ;
1348
1352
}
1349
- #line 1350 "ext/standard/var_unserializer.c"
1353
+ #line 1354 "ext/standard/var_unserializer.c"
1350
1354
yy86 :
1351
1355
++ YYCURSOR ;
1352
- #line 805 "ext/standard/var_unserializer.re"
1356
+ #line 809 "ext/standard/var_unserializer.re"
1353
1357
{
1354
1358
zend_long elements = parse_iv (start + 2 );
1355
1359
/* use iv() not uiv() in order to check data range */
1356
1360
* p = YYCURSOR ;
1357
1361
if (!var_hash ) return 0 ;
1358
1362
1359
- if (elements < 0 ) {
1363
+ if (elements < 0 || elements >= HT_MAX_SIZE ) {
1360
1364
return 0 ;
1361
1365
}
1362
1366
@@ -1373,7 +1377,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1373
1377
1374
1378
return finish_nested_data (UNSERIALIZE_PASSTHRU );
1375
1379
}
1376
- #line 1377 "ext/standard/var_unserializer.c"
1380
+ #line 1381 "ext/standard/var_unserializer.c"
1377
1381
yy88 :
1378
1382
yych = * ++ YYCURSOR ;
1379
1383
if (yych <= ',' ) {
@@ -1398,21 +1402,21 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1398
1402
goto yy18 ;
1399
1403
yy92 :
1400
1404
++ YYCURSOR ;
1401
- #line 829 "ext/standard/var_unserializer.re"
1405
+ #line 833 "ext/standard/var_unserializer.re"
1402
1406
{
1403
1407
long elements ;
1404
1408
if (!var_hash ) return 0 ;
1405
1409
1406
1410
elements = object_common1 (UNSERIALIZE_PASSTHRU , ZEND_STANDARD_CLASS_DEF_PTR );
1407
- if (elements < 0 ) {
1411
+ if (elements < 0 || elements >= HT_MAX_SIZE ) {
1408
1412
return 0 ;
1409
1413
}
1410
1414
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1411
1415
}
1412
- #line 1413 "ext/standard/var_unserializer.c"
1416
+ #line 1417 "ext/standard/var_unserializer.c"
1413
1417
yy94 :
1414
1418
++ YYCURSOR ;
1415
- #line 739 "ext/standard/var_unserializer.re"
1419
+ #line 743 "ext/standard/var_unserializer.re"
1416
1420
{
1417
1421
size_t len , maxlen ;
1418
1422
char * str ;
@@ -1444,15 +1448,15 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1444
1448
ZVAL_STRINGL (rval , str , len );
1445
1449
return 1 ;
1446
1450
}
1447
- #line 1448 "ext/standard/var_unserializer.c"
1451
+ #line 1452 "ext/standard/var_unserializer.c"
1448
1452
yy96 :
1449
1453
yych = * ++ YYCURSOR ;
1450
1454
if (yych <= '/' ) goto yy18 ;
1451
1455
if (yych <= '9' ) goto yy89 ;
1452
1456
goto yy18 ;
1453
1457
yy97 :
1454
1458
++ YYCURSOR ;
1455
- #line 714 "ext/standard/var_unserializer.re"
1459
+ #line 718 "ext/standard/var_unserializer.re"
1456
1460
{
1457
1461
* p = YYCURSOR ;
1458
1462
@@ -1468,9 +1472,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1468
1472
1469
1473
return 1 ;
1470
1474
}
1471
- #line 1472 "ext/standard/var_unserializer.c"
1475
+ #line 1476 "ext/standard/var_unserializer.c"
1472
1476
}
1473
- #line 1000 "ext/standard/var_unserializer.re"
1477
+ #line 1004 "ext/standard/var_unserializer.re"
1474
1478
1475
1479
1476
1480
return 0 ;
0 commit comments