From 61b7ed6bf0718c2b4a93350f130e8b13f980c823 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 15 May 2019 15:08:30 -0700 Subject: Fix few ASAN issues reported - Fix a Use After Free issue in Gnss Update Config If Engine Capabilities are not known yet at the time of the MsgGnssUpdateConfig, the ids arrray will be freed but the ids pointer will be copied into a new MsgGnssUpdateConfig that will access the ids array again - Issue in NetworkInfoDataItemBase which will result in array out of bound access which might result in heap buffer overflow. Change-Id: Ib5a6dc29fef9eb6676d4605f92d60f26a47d1d90 CRs-fixed: 2449980 --- gnss/GnssAdapter.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'gnss') diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index e1143fd..6558714 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -997,9 +997,18 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mConfig(config), mCount(count), mIds(ids) {} + inline MsgGnssUpdateConfig(const MsgGnssUpdateConfig& obj) : + MsgGnssUpdateConfig(obj.mAdapter, obj.mApi, obj.mConfig, + new uint32_t[obj.mCount], obj.mCount) { + if (mIds != nullptr) { + for (int i = 0; i < mCount; ++i) { + mIds[i] = obj.mIds[i]; + } + } + } inline virtual ~MsgGnssUpdateConfig() { - delete [] mIds; + delete[] mIds; } inline virtual void proc() const { @@ -1257,6 +1266,16 @@ GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) { mConfigMask(configMask), mIds(ids), mCount(count) {} + + inline MsgGnssGetConfig(const MsgGnssGetConfig& obj) : + MsgGnssGetConfig(obj.mAdapter, obj.mApi, obj.mConfigMask, + new uint32_t[obj.mCount], obj.mCount) { + if (mIds != nullptr) { + for (int i = 0; i < mCount; ++i) { + mIds[i] = obj.mIds[i]; + } + } + } inline virtual ~MsgGnssGetConfig() { delete[] mIds; -- cgit v1.2.3