Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f

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

Change-Id: I9a6def9ff590fdadb457e9a011df3532829d23f4
This commit is contained in:
TreeHugger Robot 2020-07-31 19:45:35 +00:00 committed by Automerger Merge Worker
commit cf91151364
1 changed files with 4 additions and 0 deletions

View File

@ -190,6 +190,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;