diff options
author | Sergio Giro <sgiro@google.com> | 2015-08-18 14:44:54 +0100 |
---|---|---|
committer | Sergio Giro <sgiro@google.com> | 2015-08-18 14:44:54 +0100 |
commit | 4eeacbeec0ae66e9d9395abbf83666709f2e11e3 (patch) | |
tree | 54b71bd364e6d2fe716267d893425011bdd924ad /libutils/String8.cpp | |
parent | 516d30d5029c101ef32b600d3143513d3ce16933 (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
Diffstat (limited to 'libutils/String8.cpp')
-rw-r--r-- | libutils/String8.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libutils/String8.cpp b/libutils/String8.cpp index 28be60fb5..69313ead7 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -79,6 +79,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) { |