commit | f8788be0545340e09672997a064de8627ade1574 | [log] [tgz] |
---|---|---|
author | TreeHugger Robot <treehugger-gerrit@google.com> | Fri Jul 31 19:24:50 2020 +0000 |
committer | Android (Google) Code Review <android-gerrit@google.com> | Fri Jul 31 19:24:50 2020 +0000 |
tree | e7d4bee5666465188a56529614b9cce432ed2e6e | |
parent | 3b0abc441bac16d0bfdee5e798a4fcf793b9ee70 [diff] | |
parent | c44772fdd289b8b0ec9dab562bd2d3938c81477e [diff] |
Merge "Fail explicitly on length overflow." into oc-dev
diff --git a/libutils/FileMap.cpp b/libutils/FileMap.cpp index 1afa1ec..b9f411e 100644 --- a/libutils/FileMap.cpp +++ b/libutils/FileMap.cpp
@@ -182,6 +182,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;