commit | 849e74b4c524e31f4abcba6c8057c51704ec3514 | [log] [tgz] |
---|---|---|
author | TreeHugger Robot <treehugger-gerrit@google.com> | Fri Jul 31 20:24:42 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Jul 31 20:24:42 2020 +0000 |
tree | 12f0704d7323ba8131f1a9d5e2bf865b894c7fe3 | |
parent | e1cf012ff0cca60b378756b24ed4e97baa9ffe18 [diff] | |
parent | d6297be44d310c8985ebb3b238ef5fc0c59634c9 [diff] |
Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364 am: 84dcff4c6b Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803 Change-Id: Ie7b7a57f55ead23f8d382ac98eb5087a2c614b1b
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;