commit | d6297be44d310c8985ebb3b238ef5fc0c59634c9 | [log] [tgz] |
---|---|---|
author | TreeHugger Robot <treehugger-gerrit@google.com> | Fri Jul 31 20:03:44 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Jul 31 20:03:44 2020 +0000 |
tree | 1d48da5983c9177c2c53e4629efc42da0d863d29 | |
parent | 31f1a8118646230d73c57caf83ddc0f34bbd2f7d [diff] | |
parent | f69c785d81abb72c2018e2433d348e78daea0bd7 [diff] |
Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364 Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803 Change-Id: Idb480f2a4dc1aa0d929e17e7e568a9c1b05c8489
diff --git a/libutils/FileMap.cpp b/libutils/FileMap.cpp index 3c4d81c..2e19d66 100644 --- a/libutils/FileMap.cpp +++ b/libutils/FileMap.cpp
@@ -190,6 +190,10 @@ 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;