com php-src: Fix bug #67252: convert_uudecode out-of-bounds read: ext/standard/tests/strings/bug67252.ph pt ext/standard/uuencode.c
| From: | Johannes Schlüter | Date: | Fri, 18 Jul 2014 23:05:52 +0000 |
| Subject: | com php-src: Fix bug #67252: convert_uudecode out-of-bounds read: ext/standard/tests/strings/bug67252.ph pt ext/standard/uuencode.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79634@lists.php.net to get a copy of this message | ||
Commit: 7f527897fe3e333f43bbed67741287d355ab4b2b
Author: Stanislav Malyshev <stas@php.net> Sun, 11 May 2014 20:29:27 -0700
Parents: d4b67896ecb248796a0493a9d6205b22c7dff4e2
Branches: PHP-5.3
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7f527897fe3e333f43bbed67741287d355ab4b2b
Log:
Fix bug #67252: convert_uudecode out-of-bounds read
Bugs:
https://bugs.php.net/67252
Changed paths:
A ext/standard/tests/strings/bug67252.phpt
M ext/standard/uuencode.c
Diff:
diff --git a/ext/standard/tests/strings/bug67252.phpt b/ext/standard/tests/strings/bug67252.phpt
new file mode 100644
index 0000000..80a6ebc
--- /dev/null
+++ b/ext/standard/tests/strings/bug67252..phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #67252 (convert_uudecode out-of-bounds read)
+--FILE--
+<?php
+
+$a =
"M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A"."\n"."a.";
+var_dump(convert_uudecode($a));
+
+?>
+--EXPECTF--
+
+Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d
+bool(false)
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index f0142ed..212ab70 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -151,6 +151,9 @@ PHPAPI int php_uudecode(char *src, int src_len, char **dest) /* {{{ */
}
while (s < ee) {
+ if(s+4 > e) {
+ goto err;
+ }
*p++ = PHP_UU_DEC(*s) << 2 | PHP_UU_DEC(*(s + 1)) >> 4;
*p++ = PHP_UU_DEC(*(s + 1)) << 4 | PHP_UU_DEC(*(s + 2)) >> 2;
*p++ = PHP_UU_DEC(*(s + 2)) << 6 | PHP_UU_DEC(*(s + 3));