summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKevin Rocard <krocard@google.com>2017-04-03 11:51:13 -0700
committerHridya Valsaraju <hridya@google.com>2017-04-03 17:05:28 -0700
commit1d6e40f58c939445b76d858655fb8d936fbb76fc (patch)
tree6f78e5b6ebb45d828d78059748a45c71e5f47014 /include
parentf542b5a8383ff3d03b1735f72a9524b5edf31071 (diff)
downloadplatform_system_libfmq-1d6e40f58c939445b76d858655fb8d936fbb76fc.tar.gz
platform_system_libfmq-1d6e40f58c939445b76d858655fb8d936fbb76fc.tar.bz2
platform_system_libfmq-1d6e40f58c939445b76d858655fb8d936fbb76fc.zip
Fix potential overflow in MessageQueue
Bug: 36860231 Test: make and run FMQ unit tests Change-Id: I283380aecc9062b1cee548a9087339c2d6a8c7ce Merged-In: I283380aecc9062b1cee548a9087339c2d6a8c7ce
Diffstat (limited to 'include')
-rw-r--r--include/fmq/MessageQueue.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/fmq/MessageQueue.h b/include/fmq/MessageQueue.h
index b8a4c2f..6f315b2 100644
--- a/include/fmq/MessageQueue.h
+++ b/include/fmq/MessageQueue.h
@@ -628,6 +628,11 @@ MessageQueue<T, flavor>::MessageQueue(const Descriptor& Desc, bool resetPointers
template <typename T, MQFlavor flavor>
MessageQueue<T, flavor>::MessageQueue(size_t numElementsInQueue, bool configureEventFlagWord) {
+
+ // Check if the buffer size would not overflow size_t
+ if (numElementsInQueue > SIZE_MAX / sizeof(T)) {
+ return;
+ }
/*
* The FMQ needs to allocate memory for the ringbuffer as well as for the
* read and write pointer counters. If an EventFlag word is to be configured,