1
- /* Generated by re2c 0.16 */
1
+ /* Generated by re2c 1.0.1 */
2
2
#line 1 "ext/standard/var_unserializer.re"
3
3
/*
4
4
+----------------------------------------------------------------------+
@@ -477,16 +477,22 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
477
477
return 0 ;
478
478
}
479
479
480
+ /* Check that '}' is present before calling ce->unserialize() to mitigate issues
481
+ * with unserialize reading past the end of the passed buffer if the string is not
482
+ * appropriately terminated (usually NUL terminated, but '}' is also sufficient.) */
483
+ if ((* p )[datalen ] != '}' ) {
484
+ return 0 ;
485
+ }
486
+
480
487
if (ce -> unserialize == NULL ) {
481
488
zend_error (E_WARNING , "Class %s has no unserializer" , ZSTR_VAL (ce -> name ));
482
489
object_init_ex (rval , ce );
483
490
} else if (ce -> unserialize (rval , ce , (const unsigned char * )* p , datalen , (zend_unserialize_data * )var_hash ) != SUCCESS ) {
484
491
return 0 ;
485
492
}
486
493
487
- (* p ) += datalen ;
488
-
489
- return finish_nested_data (UNSERIALIZE_PASSTHRU );
494
+ (* p ) += datalen + 1 ; /* +1 for '}' */
495
+ return 1 ;
490
496
}
491
497
492
498
static inline zend_long object_common1 (UNSERIALIZE_PARAMETER , zend_class_entry * ce )
@@ -603,7 +609,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
603
609
start = cursor ;
604
610
605
611
606
- #line 607 "ext/standard/var_unserializer.c"
612
+ #line 613 "ext/standard/var_unserializer.c"
607
613
{
608
614
YYCTYPE yych ;
609
615
static const unsigned char yybm [] = {
@@ -661,9 +667,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
661
667
yy2 :
662
668
++ YYCURSOR ;
663
669
yy3 :
664
- #line 982 "ext/standard/var_unserializer.re"
670
+ #line 988 "ext/standard/var_unserializer.re"
665
671
{ return 0 ; }
666
- #line 667 "ext/standard/var_unserializer.c"
672
+ #line 673 "ext/standard/var_unserializer.c"
667
673
yy4 :
668
674
yych = * (YYMARKER = ++ YYCURSOR );
669
675
if (yych == ':' ) goto yy17 ;
@@ -710,13 +716,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
710
716
goto yy3 ;
711
717
yy15 :
712
718
++ YYCURSOR ;
713
- #line 976 "ext/standard/var_unserializer.re"
719
+ #line 982 "ext/standard/var_unserializer.re"
714
720
{
715
721
/* this is the case where we have less data than planned */
716
722
php_error_docref (NULL , E_NOTICE , "Unexpected end of serialized data" );
717
723
return 0 ; /* not sure if it should be 0 or 1 here? */
718
724
}
719
- #line 720 "ext/standard/var_unserializer.c"
725
+ #line 726 "ext/standard/var_unserializer.c"
720
726
yy17 :
721
727
yych = * ++ YYCURSOR ;
722
728
if (yybm [0 + yych ] & 128 ) {
@@ -728,13 +734,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
728
734
goto yy3 ;
729
735
yy19 :
730
736
++ YYCURSOR ;
731
- #line 660 "ext/standard/var_unserializer.re"
737
+ #line 666 "ext/standard/var_unserializer.re"
732
738
{
733
739
* p = YYCURSOR ;
734
740
ZVAL_NULL (rval );
735
741
return 1 ;
736
742
}
737
- #line 738 "ext/standard/var_unserializer.c"
743
+ #line 744 "ext/standard/var_unserializer.c"
738
744
yy21 :
739
745
yych = * ++ YYCURSOR ;
740
746
if (yych <= ',' ) {
@@ -984,7 +990,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
984
990
goto yy18 ;
985
991
yy63 :
986
992
++ YYCURSOR ;
987
- #line 611 "ext/standard/var_unserializer.re"
993
+ #line 617 "ext/standard/var_unserializer.re"
988
994
{
989
995
zend_long id ;
990
996
@@ -1009,7 +1015,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1009
1015
1010
1016
return 1 ;
1011
1017
}
1012
- #line 1013 "ext/standard/var_unserializer.c"
1018
+ #line 1019 "ext/standard/var_unserializer.c"
1013
1019
yy65 :
1014
1020
yych = * ++ YYCURSOR ;
1015
1021
if (yych == '"' ) goto yy84 ;
@@ -1020,13 +1026,13 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1020
1026
goto yy18 ;
1021
1027
yy67 :
1022
1028
++ YYCURSOR ;
1023
- #line 666 "ext/standard/var_unserializer.re"
1029
+ #line 672 "ext/standard/var_unserializer.re"
1024
1030
{
1025
1031
* p = YYCURSOR ;
1026
1032
ZVAL_BOOL (rval , parse_iv (start + 2 ));
1027
1033
return 1 ;
1028
1034
}
1029
- #line 1030 "ext/standard/var_unserializer.c"
1035
+ #line 1036 "ext/standard/var_unserializer.c"
1030
1036
yy69 :
1031
1037
++ YYCURSOR ;
1032
1038
if ((YYLIMIT - YYCURSOR ) < 4 ) YYFILL (4 );
@@ -1046,7 +1052,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1046
1052
}
1047
1053
yy71 :
1048
1054
++ YYCURSOR ;
1049
- #line 714 "ext/standard/var_unserializer.re"
1055
+ #line 720 "ext/standard/var_unserializer.re"
1050
1056
{
1051
1057
#if SIZEOF_ZEND_LONG == 4
1052
1058
use_double :
@@ -1055,7 +1061,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1055
1061
ZVAL_DOUBLE (rval , zend_strtod ((const char * )start + 2 , NULL ));
1056
1062
return 1 ;
1057
1063
}
1058
- #line 1059 "ext/standard/var_unserializer.c"
1064
+ #line 1065 "ext/standard/var_unserializer.c"
1059
1065
yy73 :
1060
1066
yych = * ++ YYCURSOR ;
1061
1067
if (yych <= ',' ) {
@@ -1077,7 +1083,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1077
1083
goto yy18 ;
1078
1084
yy76 :
1079
1085
++ YYCURSOR ;
1080
- #line 672 "ext/standard/var_unserializer.re"
1086
+ #line 678 "ext/standard/var_unserializer.re"
1081
1087
{
1082
1088
#if SIZEOF_ZEND_LONG == 4
1083
1089
int digits = YYCURSOR - start - 3 ;
@@ -1103,14 +1109,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1103
1109
ZVAL_LONG (rval , parse_iv (start + 2 ));
1104
1110
return 1 ;
1105
1111
}
1106
- #line 1107 "ext/standard/var_unserializer.c"
1112
+ #line 1113 "ext/standard/var_unserializer.c"
1107
1113
yy78 :
1108
1114
yych = * ++ YYCURSOR ;
1109
1115
if (yych == '"' ) goto yy92 ;
1110
1116
goto yy18 ;
1111
1117
yy79 :
1112
1118
++ YYCURSOR ;
1113
- #line 636 "ext/standard/var_unserializer.re"
1119
+ #line 642 "ext/standard/var_unserializer.re"
1114
1120
{
1115
1121
zend_long id ;
1116
1122
@@ -1134,14 +1140,14 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1134
1140
1135
1141
return 1 ;
1136
1142
}
1137
- #line 1138 "ext/standard/var_unserializer.c"
1143
+ #line 1144 "ext/standard/var_unserializer.c"
1138
1144
yy81 :
1139
1145
yych = * ++ YYCURSOR ;
1140
1146
if (yych == '"' ) goto yy94 ;
1141
1147
goto yy18 ;
1142
1148
yy82 :
1143
1149
++ YYCURSOR ;
1144
- #line 824 "ext/standard/var_unserializer.re"
1150
+ #line 830 "ext/standard/var_unserializer.re"
1145
1151
{
1146
1152
size_t len , len2 , len3 , maxlen ;
1147
1153
zend_long elements ;
@@ -1293,10 +1299,10 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1293
1299
1294
1300
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1295
1301
}
1296
- #line 1297 "ext/standard/var_unserializer.c"
1302
+ #line 1303 "ext/standard/var_unserializer.c"
1297
1303
yy84 :
1298
1304
++ YYCURSOR ;
1299
- #line 755 "ext/standard/var_unserializer.re"
1305
+ #line 761 "ext/standard/var_unserializer.re"
1300
1306
{
1301
1307
size_t len , maxlen ;
1302
1308
zend_string * str ;
@@ -1330,10 +1336,10 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1330
1336
ZVAL_STR (rval , str );
1331
1337
return 1 ;
1332
1338
}
1333
- #line 1334 "ext/standard/var_unserializer.c"
1339
+ #line 1340 "ext/standard/var_unserializer.c"
1334
1340
yy86 :
1335
1341
++ YYCURSOR ;
1336
- #line 789 "ext/standard/var_unserializer.re"
1342
+ #line 795 "ext/standard/var_unserializer.re"
1337
1343
{
1338
1344
zend_long elements = parse_iv (start + 2 );
1339
1345
/* use iv() not uiv() in order to check data range */
@@ -1357,7 +1363,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1357
1363
1358
1364
return finish_nested_data (UNSERIALIZE_PASSTHRU );
1359
1365
}
1360
- #line 1361 "ext/standard/var_unserializer.c"
1366
+ #line 1367 "ext/standard/var_unserializer.c"
1361
1367
yy88 :
1362
1368
yych = * ++ YYCURSOR ;
1363
1369
if (yych <= ',' ) {
@@ -1382,7 +1388,7 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1382
1388
goto yy18 ;
1383
1389
yy92 :
1384
1390
++ YYCURSOR ;
1385
- #line 813 "ext/standard/var_unserializer.re"
1391
+ #line 819 "ext/standard/var_unserializer.re"
1386
1392
{
1387
1393
zend_long elements ;
1388
1394
if (!var_hash ) return 0 ;
@@ -1393,10 +1399,10 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1393
1399
}
1394
1400
return object_common2 (UNSERIALIZE_PASSTHRU , elements );
1395
1401
}
1396
- #line 1397 "ext/standard/var_unserializer.c"
1402
+ #line 1403 "ext/standard/var_unserializer.c"
1397
1403
yy94 :
1398
1404
++ YYCURSOR ;
1399
- #line 723 "ext/standard/var_unserializer.re"
1405
+ #line 729 "ext/standard/var_unserializer.re"
1400
1406
{
1401
1407
size_t len , maxlen ;
1402
1408
char * str ;
@@ -1428,15 +1434,15 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1428
1434
ZVAL_STRINGL (rval , str , len );
1429
1435
return 1 ;
1430
1436
}
1431
- #line 1432 "ext/standard/var_unserializer.c"
1437
+ #line 1438 "ext/standard/var_unserializer.c"
1432
1438
yy96 :
1433
1439
yych = * ++ YYCURSOR ;
1434
1440
if (yych <= '/' ) goto yy18 ;
1435
1441
if (yych <= '9' ) goto yy89 ;
1436
1442
goto yy18 ;
1437
1443
yy97 :
1438
1444
++ YYCURSOR ;
1439
- #line 698 "ext/standard/var_unserializer.re"
1445
+ #line 704 "ext/standard/var_unserializer.re"
1440
1446
{
1441
1447
* p = YYCURSOR ;
1442
1448
@@ -1452,9 +1458,9 @@ static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
1452
1458
1453
1459
return 1 ;
1454
1460
}
1455
- #line 1456 "ext/standard/var_unserializer.c"
1461
+ #line 1462 "ext/standard/var_unserializer.c"
1456
1462
}
1457
- #line 984 "ext/standard/var_unserializer.re"
1463
+ #line 990 "ext/standard/var_unserializer.re"
1458
1464
1459
1465
1460
1466
return 0 ;
0 commit comments