Merge "libutils: check vsnprintf error" 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;