com php-src: fix CVE-2013-2110 - use correct formula to calculate string size: ext/standard/quot_print.c ext/standard/tests/string s/bug64879.phpt
| From: | Johannes Schlüter | Date: | Wed, 05 Jun 2013 14:24:12 +0000 |
| Subject: | com php-src: fix CVE-2013-2110 - use correct formula to calculate string size: ext/standard/quot_print.c ext/standard/tests/string s/bug64879.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72313@lists.php.net to get a copy of this message | ||
Commit: eeb7f93294cd0a11af44905d84044e0b158d802c
Author: Stanislav Malyshev <stas@php.net> Mon, 20 May 2013 00:43:29 -0700
Committer: Johannes Schlüter <johannes@php.net> Wed, 5 Jun 2013 16:24:12 +0200
Parents: 9e28f20fba538c602ff3270deeb4aa5835448866
Branches: PHP-5.3.26
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eeb7f93294cd0a11af44905d84044e0b158d802c
Log:
fix CVE-2013-2110 - use correct formula to calculate string size
Changed paths:
M ext/standard/quot_print.c
A ext/standard/tests/strings/bug64879.phpt
Diff:
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index 280b86a..6627858 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -151,7 +151,7 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t len
unsigned char c, *ret, *d;
char *hex = "0123456789ABCDEF";
- ret = safe_emalloc(1, 3 * length + 3 * (((3 * length)/PHP_QPRINT_MAXL) + 1), 0);
+ ret = safe_emalloc(3, length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1), 1);
d = ret;
while (length--) {
diff --git a/ext/standard/tests/strings/bug64879.phpt b/ext/standard/tests/strings/bug64879.phpt
new file mode 100644
index 0000000..1df90c6
--- /dev/null
+++ b/ext/standard/tests/strings/bug64879.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #64879: quoted_printable_encode() wrong size calculation (CVE-2013-2110)
+--FILE--
+<?php
+
+quoted_printable_encode(str_repeat("\xf4", 1000));
+quoted_printable_encode(str_repeat("\xf4", 100000));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Done