commit | 5b5c17b6443914a23b2ee0af245c0c83ac6026ed | [log] [tgz] |
---|---|---|
author | sirius.wang <sirius.wang@mediatek.corp-partner.google.com> | Fri Aug 28 16:20:40 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Aug 28 16:20:40 2020 +0000 |
tree | 6160a0766fbbfb1f3eac1cd1769b4650eead51d2 | |
parent | 88cb3736cd0f7978025aa83db8001b98393a65db [diff] | |
parent | 4c8901de2933bdabd824d62c0ee9a6dfea083adb [diff] |
fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol. am: 767fe1515a Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12448097 Change-Id: I4e1233336d3de093d31aecfd377451114461de46
diff --git a/libutils/String8.cpp b/libutils/String8.cpp index d13548e..9d50e0b 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp
@@ -322,8 +322,14 @@ n = vsnprintf(nullptr, 0, fmt, tmp_args); va_end(tmp_args); - if (n != 0) { + if (n < 0) return UNKNOWN_ERROR; + + if (n > 0) { size_t oldLength = length(); + if ((size_t)n > SIZE_MAX - 1 || + oldLength > SIZE_MAX - (size_t)n - 1) { + return NO_MEMORY; + } char* buf = lockBuffer(oldLength + n); if (buf) { vsnprintf(buf + oldLength, n + 1, fmt, args);