Skip to content

Commit 93e0d78

Browse files
committed
fix CVE-2013-2110 - use correct formula to calculate string size
1 parent 2463e89 commit 93e0d78

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818

1919
### DO NOT ADD ENTRIES HERE, ADD THEM ABOVE FOR 5.3.27 ###
2020

21+
- Core:
22+
. Fixed bug #64879 (Heap based buffer overflow in quoted_printable_encode,
23+
CVE 2013-2110). (Stas)
24+
2125
- Calendar:
2226
. Fixed bug #64895 (Integer overflow in SndToJewish). (Remi)
2327

ext/standard/quot_print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t len
151151
unsigned char c, *ret, *d;
152152
char *hex = "0123456789ABCDEF";
153153

154-
ret = safe_emalloc(1, 3 * length + 3 * (((3 * length)/PHP_QPRINT_MAXL) + 1), 0);
154+
ret = safe_emalloc(3, length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1), 1);
155155
d = ret;
156156

157157
while (length--) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #64879: quoted_printable_encode() wrong size calculation (CVE-2013-2110)
3+
--FILE--
4+
<?php
5+
6+
quoted_printable_encode(str_repeat("\xf4", 1000));
7+
quoted_printable_encode(str_repeat("\xf4", 100000));
8+
9+
echo "Done\n";
10+
?>
11+
--EXPECTF--
12+
Done

0 commit comments

Comments
 (0)