File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ var_dump(unserialize($s));
8
8
--EXPECTF--
9
9
Warning: unserialize(): %s in %sbug74101.php on line %d
10
10
11
- Notice: unserialize(): Error at offset 48 of 74 bytes in %sbug74101.php on line %d
11
+ Notice: unserialize(): Error at offset 46 of 74 bytes in %sbug74101.php on line %d
12
12
bool(false)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Unserializing payload with unrealistically large element counts
3
+ --FILE--
4
+ <?php
5
+
6
+ var_dump (unserialize ("a:1000000000:{} " ));
7
+ var_dump (unserialize ("O:1000000000: \"\":0:{} " ));
8
+ var_dump (unserialize ("O:1: \"X \":1000000000:{} " ));
9
+ var_dump (unserialize ("C:1: \"X \":1000000000:{} " ));
10
+
11
+ ?>
12
+ --EXPECTF--
13
+ Notice: unserialize(): Error at offset 14 of 15 bytes in %s on line %d
14
+ bool(false)
15
+
16
+ Notice: unserialize(): Error at offset 2 of 20 bytes in %s on line %d
17
+ bool(false)
18
+
19
+ Notice: unserialize(): Error at offset 18 of 21 bytes in %s on line %d
20
+ bool(false)
21
+
22
+ Warning: Insufficient data for unserializing - 1000000000 required, 1 present in %s on line %d
23
+
24
+ Notice: unserialize(): Error at offset 20 of 21 bytes in %s on line %d
25
+ bool(false)
Original file line number Diff line number Diff line change @@ -953,7 +953,7 @@ use_double:
953
953
*p = YYCURSOR;
954
954
if (!var_hash) return 0;
955
955
956
- if (elements < 0 || elements >= HT_MAX_SIZE) {
956
+ if (elements < 0 || elements >= HT_MAX_SIZE || elements > max - YYCURSOR ) {
957
957
return 0;
958
958
}
959
959
@@ -1124,10 +1124,11 @@ object ":" uiv ":" ["] {
1124
1124
}
1125
1125
1126
1126
elements = parse_iv2 (*p + 2 , p);
1127
- if (elements < 0 ) {
1127
+ if (elements < 0 || elements > max - YYCURSOR ) {
1128
1128
zend_string_release_ex (class_name, 0 );
1129
1129
return 0 ;
1130
1130
}
1131
+
1131
1132
*p += 2 ;
1132
1133
1133
1134
has_unserialize = !incomplete_class
You can’t perform that action at this time.
0 commit comments