summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-07-27 18:47:50 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-07-27 18:47:50 +0000
commitf46469019c0fa1cee9e186004c3e325743d9ebec (patch)
treed638624afaff061ebb012e2c7706046a43e72a16
parent490a126f946857e1ad9e4c281e5c115c13516d6c (diff)
parent93484b9b015d47c0f7e5f4449a214b2fed8bed4f (diff)
downloadlibhidl-pie-r2-s1-release.tar.gz
Change-Id: Ie8690bcc9e63cdb70ab81791244446a56ef46eb9
-rw-r--r--transport/HidlBinderSupport.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index d14887f..4f8d7c5 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -19,6 +19,7 @@
#include <hidl/HidlBinderSupport.h>
// C includes
+#include <inttypes.h>
#include <unistd.h>
// C++ includes
@@ -66,6 +67,15 @@ status_t readEmbeddedFromParcel(const hidl_memory& memory,
parentOffset + hidl_memory::kOffsetOfName);
}
+ // hidl_memory's size is stored in uint64_t, but mapMemory's mmap will map
+ // size in size_t. If size is over SIZE_MAX, mapMemory could succeed
+ // but the mapped memory's actual size will be smaller than the reported size.
+ if (memory.size() > SIZE_MAX) {
+ ALOGE("Cannot use memory with %" PRId64 " bytes because it is too large.", memory.size());
+ android_errorWriteLog(0x534e4554, "79376389");
+ return BAD_VALUE;
+ }
+
return _hidl_err;
}