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

Commit 4d143036 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Fail explicitly on length overflow.

Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c)
parent e62a9d76
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -182,6 +182,10 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
    adjust = offset % mPageSize;
    adjOffset = offset - adjust;
    adjLength = length + adjust;
    if (__builtin_add_overflow(length, adjust, &adjLength)) {
        ALOGE("adjusted length overflow: length %zu adjust %d", length, adjust);
        return false;
    }

    flags = MAP_SHARED;
    prot = PROT_READ;