summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2015-08-18 14:44:54 +0100
committerThe Android Automerger <android-build@google.com>2015-09-08 13:31:13 -0700
commitd41177ba926616e4ae0e198628d5b3df7aaaa475 (patch)
treed67a42c4c32f8daa75473e24051847a5dc84bf99
parent3267776187b72f9fb7750b13445eda05b10e321c (diff)
downloadcore-d41177ba926616e4ae0e198628d5b3df7aaaa475.tar.gz
libutils: fix overflow in String8::allocFromUTF8android-5.1.1_r22
Patch contributed in: https://code.google.com/p/android/issues/detail?id=182908 Bug: 23290056 (cherry picked from commit 4eeacbeec0ae66e9d9395abbf83666709f2e11e3) Change-Id: Ife1dc0791040150132bea6884f1e6c8d31972d1b (cherry picked from commit ebabef275283f771151ec93c17469374b789b2c8)
-rw-r--r--libutils/String8.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 40fa40ba2..d4f5c7892 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -81,6 +81,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) {