From 0f3298bd7f9adb5edbadd17c048d5fb927e1df0f Mon Sep 17 00:00:00 2001 From: Wolfgang Wiedmeyer Date: Mon, 19 Oct 2015 23:27:50 +0200 Subject: backport of fix for CVE-2015-6602 corresponding upstream commits: 5b85b1d40d619c2064d321364f212ebfeb6ba185 e0dce90b0de2b2b7c2baae8035f810a55526effb Signed-off-by: Wolfgang Wiedmeyer --- libs/utils/String8.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp index 562f026..26cf2ab 100644 --- a/libs/utils/String8.cpp +++ b/libs/utils/String8.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +#define __STDC_LIMIT_MACROS +#include + #include #include @@ -79,6 +82,9 @@ void terminate_string8() static char* allocFromUTF8(const char* in, size_t len) { if (len > 0) { + if (len == SIZE_MAX) { + return NULL; + } SharedBuffer* buf = SharedBuffer::alloc(len+1); ALOG_ASSERT(buf, "Unable to allocate shared buffer"); if (buf) { -- cgit v1.1