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

Commit 2f28c8a2 authored by Ray Essick's avatar Ray Essick Committed by Automerger Merge Worker
Browse files

Merge "Better buffer-overrun prevention" into rvc-dev am: d8c535a2 am:...

Merge "Better buffer-overrun prevention" into rvc-dev am: d8c535a2 am: 5351e4b3 am: 2c09c9f2 am: 69d5a7b7 am: 2d7ac5d1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/16230693

Change-Id: Ie30467c2ebedfa3d64002cbbaedcd3fd82b665ee
parents f500db4f 2d7ac5d1
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -499,16 +499,15 @@ protected:
    template <> // static
    template <> // static
    status_t extract(std::string *val, const char **bufferpptr, const char *bufferptrmax) {
    status_t extract(std::string *val, const char **bufferpptr, const char *bufferptrmax) {
        const char *ptr = *bufferpptr;
        const char *ptr = *bufferpptr;
        while (*ptr != 0) {
        do {
            if (ptr >= bufferptrmax) {
            if (ptr >= bufferptrmax) {
                ALOGE("%s: buffer exceeded", __func__);
                ALOGE("%s: buffer exceeded", __func__);
                return BAD_VALUE;
                return BAD_VALUE;
            }
            }
            ++ptr;
        } while (*ptr++ != 0);
        }
        // ptr is terminator+1, == bufferptrmax if we finished entire buffer
        const size_t size = (ptr - *bufferpptr) + 1;
        *val = *bufferpptr;
        *val = *bufferpptr;
        *bufferpptr += size;
        *bufferpptr = ptr;
        return NO_ERROR;
        return NO_ERROR;
    }
    }
    template <> // static
    template <> // static