summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-05-11 20:29:27 -0700
committerStanislav Malyshev <stas@php.net>2014-05-11 20:29:27 -0700
commit1e2818b143760a79a0887861bd6221b158355073 (patch)
tree504775f8090d603394ebd39d0d417cb40e77963c
parent2b475eebbea85779989e98e87753d6b023a1d131 (diff)
downloadphp-git-1e2818b143760a79a0887861bd6221b158355073.tar.gz
Fix bug #67252: convert_uudecode out-of-bounds read
-rw-r--r--NEWS1
-rw-r--r--ext/standard/tests/strings/bug67252.phpt13
-rw-r--r--ext/standard/uuencode.c3
3 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 03f8b87daf..69e3b8d386 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP NEWS
. Fixed bug #67245 (usage of memcpy() with overlapping src and dst in
zend_exceptions.c). (Bob)
. Fixed bug #67247 (spl_fixedarray_resize integer overflow). (Stas)
+ . Fixed bug #67252 (convert_uudecode out-of-bounds read). (Stas)
- Date:
. Fixed bug #67118 (DateTime constructor crash with invalid data). (Anatol)
diff --git a/ext/standard/tests/strings/bug67252.phpt b/ext/standard/tests/strings/bug67252.phpt
new file mode 100644
index 0000000000..80a6ebcf1c
--- /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 52e892ed9e..8544aef9f0 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));