@@ -503,6 +503,10 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
503
503
&& zend_hash_str_exists (& Z_OBJCE_P (rval )-> function_table , "__wakeup" , sizeof ("__wakeup" )- 1 );
504
504
505
505
ht = Z_OBJPROP_P (rval );
506
+ if (elements >= HT_MAX_SIZE - zend_hash_num_elements (ht )) {
507
+ return 0 ;
508
+ }
509
+
506
510
zend_hash_extend (ht , zend_hash_num_elements (ht ) + elements , (ht -> u .flags & HASH_FLAG_PACKED ));
507
511
if (!process_nested_data (UNSERIALIZE_PASSTHRU , ht , elements , 1 )) {
508
512
if (has_wakeup ) {
@@ -578,7 +582,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
578
582
start = cursor ;
579
583
580
584
581
- #line 582 "ext/standard/var_unserializer.c"
585
+ #line 586 "ext/standard/var_unserializer.c"
582
586
{
583
587
YYCTYPE yych ;
584
588
static const unsigned char yybm [] = {
@@ -636,9 +640,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
636
640
yy2 :
637
641
++ YYCURSOR ;
638
642
yy3 :
639
- #line 959 "ext/standard/var_unserializer.re"
643
+ #line 963 "ext/standard/var_unserializer.re"
640
644
{ return 0 ; }
641
- #line 642 "ext/standard/var_unserializer.c"
645
+ #line 646 "ext/standard/var_unserializer.c"
642
646
yy4 :
643
647
yych = * (YYMARKER = ++ YYCURSOR );
644
648
if (yych == ':' ) goto yy17 ;
@@ -685,13 +689,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
685
689
goto yy3 ;
686
690
yy15 :
687
691
++ YYCURSOR ;
688
- #line 953 "ext/standard/var_unserializer.re"
692
+ #line 957 "ext/standard/var_unserializer.re"
689
693
{
690
694
/* this is the case where we have less data than planned */
691
695
php_error_docref (NULL , E_NOTICE , "Unexpected end of serialized data" );
692
696
return 0 ; /* not sure if it should be 0 or 1 here? */
693
697
}
694
- #line 695 "ext/standard/var_unserializer.c"
698
+ #line 699 "ext/standard/var_unserializer.c"
695
699
yy17 :
696
700
yych = * ++ YYCURSOR ;
697
701
if (yybm [0 + yych ] & 128 ) {
@@ -703,13 +707,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
703
707
goto yy3 ;
704
708
yy19 :
705
709
++ YYCURSOR ;
706
- #line 637 "ext/standard/var_unserializer.re"
710
+ #line 641 "ext/standard/var_unserializer.re"
707
711
{
708
712
* p = YYCURSOR ;
709
713
ZVAL_NULL (rval );
710
714
return 1 ;
711
715
}
712
- #line 713 "ext/standard/var_unserializer.c"
716
+ #line 717 "ext/standard/var_unserializer.c"
713
717
yy21 :
714
718
yych = * ++ YYCURSOR ;
715
719
if (yych <= ',' ) {
@@ -959,7 +963,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
959
963
goto yy18 ;
960
964
yy63 :
961
965
++ YYCURSOR ;
962
- #line 586 "ext/standard/var_unserializer.re"
966
+ #line 590 "ext/standard/var_unserializer.re"
963
967
{
964
968
zend_long id ;
965
969
@@ -985,7 +989,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
985
989
986
990
return 1 ;
987
991
}
988
- #line 989 "ext/standard/var_unserializer.c"
992
+ #line 993 "ext/standard/var_unserializer.c"
989
993
yy65 :
990
994
yych = * ++ YYCURSOR ;
991
995
if (yych == '"' ) goto yy84 ;
@@ -996,13 +1000,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
996
1000
goto yy18 ;
997
1001
yy67 :
998
1002
++ YYCURSOR ;
999
- #line 643 "ext/standard/var_unserializer.re"
1003
+ #line 647 "ext/standard/var_unserializer.re"
1000
1004
{
1001
1005
* p = YYCURSOR ;
1002
1006
ZVAL_BOOL (rval , parse_iv (start + 2 ));
1003
1007
return 1 ;
1004
1008
}
1005
- #line 1006 "ext/standard/var_unserializer.c"
1009
+ #line 1010 "ext/standard/var_unserializer.c"
1006
1010
yy69 :
1007
1011
++ YYCURSOR ;
1008
1012
if ((YYLIMIT - YYCURSOR ) < 4 ) YYFILL (4 );
@@ -1022,7 +1026,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1022
1026
}
1023
1027
yy71 :
1024
1028
++ YYCURSOR ;
1025
- #line 691 "ext/standard/var_unserializer.re"
1029
+ #line 695 "ext/standard/var_unserializer.re"
1026
1030
{
1027
1031
#if SIZEOF_ZEND_LONG == 4
1028
1032
use_double :
@@ -1031,7 +1035,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1031
1035
ZVAL_DOUBLE (rval , zend_strtod ((const char * )start + 2 , NULL ));
1032
1036
return 1 ;
1033
1037
}
1034
- #line 1035 "ext/standard/var_unserializer.c"
1038
+ #line 1039 "ext/standard/var_unserializer.c"
1035
1039
yy73 :
1036
1040
yych = * ++ YYCURSOR ;
1037
1041
if (yych <= ',' ) {
@@ -1053,7 +1057,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1053
1057
goto yy18 ;
1054
1058
yy76 :
1055
1059
++ YYCURSOR ;
1056
- #line 649 "ext/standard/var_unserializer.re"
1060
+ #line 653 "ext/standard/var_unserializer.re"
1057
1061
{
1058
1062
#if SIZEOF_ZEND_LONG == 4
1059
1063
int digits = YYCURSOR - start - 3 ;
@@ -1079,14 +1083,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1079
1083
ZVAL_LONG (rval , parse_iv (start + 2 ));
1080
1084
return 1 ;
1081
1085
}
1082
- #line 1083 "ext/standard/var_unserializer.c"
1086
+ #line 1087 "ext/standard/var_unserializer.c"
1083
1087
yy78 :
1084
1088
yych = * ++ YYCURSOR ;
1085
1089
if (yych == '"' ) goto yy92 ;
1086
1090
goto yy18 ;
1087
1091
yy79 :
1088
1092
++ YYCURSOR ;
1089
- #line 612 "ext/standard/var_unserializer.re"
1093
+ #line 616 "ext/standard/var_unserializer.re"
1090
1094
{
1091
1095
zend_long id ;
1092
1096
@@ -1111,14 +1115,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1111
1115
1112
1116
return 1 ;
1113
1117
}
1114
- #line 1115 "ext/standard/var_unserializer.c"
1118
+ #line 1119 "ext/standard/var_unserializer.c"
1115
1119
yy81 :
1116
1120
yych = * ++ YYCURSOR ;
1117
1121
if (yych == '"' ) goto yy94 ;
1118
1122
goto yy18 ;
1119
1123
yy82 :
1120
1124
++ YYCURSOR ;
1121
- #line 801 "ext/standard/var_unserializer.re"
1125
+ #line 805 "ext/standard/var_unserializer.re"
1122
1126
{
1123
1127
size_t len , len2 , len3 , maxlen ;
1124
1128
zend_long elements ;
@@ -1270,10 +1274,10 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1270
1274
1271
1275
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1272
1276
}
1273
- #line 1274 "ext/standard/var_unserializer.c"
1277
+ #line 1278 "ext/standard/var_unserializer.c"
1274
1278
yy84 :
1275
1279
++ YYCURSOR ;
1276
- #line 732 "ext/standard/var_unserializer.re"
1280
+ #line 736 "ext/standard/var_unserializer.re"
1277
1281
{
1278
1282
size_t len , maxlen ;
1279
1283
zend_string * str ;
@@ -1307,17 +1311,17 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1307
1311
ZVAL_STR (rval , str );
1308
1312
return 1 ;
1309
1313
}
1310
- #line 1311 "ext/standard/var_unserializer.c"
1314
+ #line 1315 "ext/standard/var_unserializer.c"
1311
1315
yy86 :
1312
1316
++ YYCURSOR ;
1313
- #line 766 "ext/standard/var_unserializer.re"
1317
+ #line 770 "ext/standard/var_unserializer.re"
1314
1318
{
1315
1319
zend_long elements = parse_iv (start + 2 );
1316
1320
/* use iv() not uiv() in order to check data range */
1317
1321
* p = YYCURSOR ;
1318
1322
if (!var_hash ) return 0 ;
1319
1323
1320
- if (elements < 0 ) {
1324
+ if (elements < 0 || elements >= HT_MAX_SIZE ) {
1321
1325
return 0 ;
1322
1326
}
1323
1327
@@ -1334,7 +1338,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1334
1338
1335
1339
return finish_nested_data (UNSERIALIZE_PASSTHRU );
1336
1340
}
1337
- #line 1338 "ext/standard/var_unserializer.c"
1341
+ #line 1342 "ext/standard/var_unserializer.c"
1338
1342
yy88 :
1339
1343
yych = * ++ YYCURSOR ;
1340
1344
if (yych <= ',' ) {
@@ -1359,21 +1363,21 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1359
1363
goto yy18 ;
1360
1364
yy92 :
1361
1365
++ YYCURSOR ;
1362
- #line 790 "ext/standard/var_unserializer.re"
1366
+ #line 794 "ext/standard/var_unserializer.re"
1363
1367
{
1364
1368
long elements ;
1365
1369
if (!var_hash ) return 0 ;
1366
1370
1367
1371
elements = object_common1 (UNSERIALIZE_PASSTHRU , ZEND_STANDARD_CLASS_DEF_PTR );
1368
- if (elements < 0 ) {
1372
+ if (elements < 0 || elements >= HT_MAX_SIZE ) {
1369
1373
return 0 ;
1370
1374
}
1371
1375
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1372
1376
}
1373
- #line 1374 "ext/standard/var_unserializer.c"
1377
+ #line 1378 "ext/standard/var_unserializer.c"
1374
1378
yy94 :
1375
1379
++ YYCURSOR ;
1376
- #line 700 "ext/standard/var_unserializer.re"
1380
+ #line 704 "ext/standard/var_unserializer.re"
1377
1381
{
1378
1382
size_t len , maxlen ;
1379
1383
char * str ;
@@ -1405,15 +1409,15 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1405
1409
ZVAL_STRINGL (rval , str , len );
1406
1410
return 1 ;
1407
1411
}
1408
- #line 1409 "ext/standard/var_unserializer.c"
1412
+ #line 1413 "ext/standard/var_unserializer.c"
1409
1413
yy96 :
1410
1414
yych = * ++ YYCURSOR ;
1411
1415
if (yych <= '/' ) goto yy18 ;
1412
1416
if (yych <= '9' ) goto yy89 ;
1413
1417
goto yy18 ;
1414
1418
yy97 :
1415
1419
++ YYCURSOR ;
1416
- #line 675 "ext/standard/var_unserializer.re"
1420
+ #line 679 "ext/standard/var_unserializer.re"
1417
1421
{
1418
1422
* p = YYCURSOR ;
1419
1423
@@ -1429,9 +1433,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1429
1433
1430
1434
return 1 ;
1431
1435
}
1432
- #line 1433 "ext/standard/var_unserializer.c"
1436
+ #line 1437 "ext/standard/var_unserializer.c"
1433
1437
}
1434
- #line 961 "ext/standard/var_unserializer.re"
1438
+ #line 965 "ext/standard/var_unserializer.re"
1435
1439
1436
1440
1437
1441
return 0 ;
0 commit comments