commit | f69c785d81abb72c2018e2433d348e78daea0bd7 | [log] [tgz] |
---|---|---|
author | TreeHugger Robot <treehugger-gerrit@google.com> | Fri Jul 31 19:45:35 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Jul 31 19:45:35 2020 +0000 |
tree | 208e4b1eb5f664cdf6df26db8fcfd7f51066cbd3 | |
parent | 71d373aebc23b7a9750c8f90c63b9821354299ee [diff] | |
parent | f8788be0545340e09672997a064de8627ade1574 [diff] |
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
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;