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

Commit 5ec65ae9 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Check for null-terminator in ResStringPool::string8At

All other stringAt methods check for null termination. Be consistent
so that upper levels don't end up with huge corrupt strings.

Bug: 62537081
Test: none
Change-Id: I17bdfb0c1e34507b66c6cad651bbdb12c5d4c417
(cherry picked from commit 3d35a0ea)
(cherry picked from commit 97f8cb01149b35b1832c7f9efe85ff19edf1083e)
parent 6a9c7c48
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -785,6 +785,12 @@ const char* ResStringPool::string8At(size_t idx, size_t* outLen) const
            *outLen = decodeLength(&str);
            size_t encLen = decodeLength(&str);
            if ((uint32_t)(str+encLen-strings) < mStringPoolSize) {
                // Reject malformed (non null-terminated) strings
                if (str[encLen] != 0x00) {
                    ALOGW("Bad string block: string #%d is not null-terminated",
                          (int)idx);
                    return NULL;
                }
              return (const char*)str;
            } else {
                ALOGW("Bad string block: string #%d extends to %d, past end at %d\n",