Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc99a094 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d5 am: d8801aaa am: d05ecb8d

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I816b8858c69e6481299f942401a16b5b39cd8b69
parents cf6c14c8 d05ecb8d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -346,8 +346,14 @@ status_t String8::appendFormatV(const char* fmt, va_list args)
    n = vsnprintf(NULL, 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);