commit | 1389599ae38fd7c5685b33ba9238b29269a54df6 | [log] [tgz] |
---|---|---|
author | Sergio Giro <sgiro@google.com> | Tue Aug 18 14:44:54 2015 +0100 |
committer | Sergio Giro <sgiro@google.com> | Tue Aug 18 14:44:54 2015 +0100 |
tree | 54b71bd364e6d2fe716267d893425011bdd924ad | |
parent | 5fd3cf5bae209118f3b038f7f2c503cdb1f383d7 [diff] |
libutils: fix overflow in String8::allocFromUTF8 Patch contributed in: https://code.google.com/p/android/issues/detail?id=182908 Bug: 23290056 Change-Id: Ide0e9a8acc4e95a9104bab3ae803aa3a40098222
diff --git a/libutils/String8.cpp b/libutils/String8.cpp index 28be60f..69313ea 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp
@@ -79,6 +79,9 @@ 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) {