From 8af6be402eba48a02853bebc5f9f6d5b9e8844f3 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 23 Jul 2020 15:37:29 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - libmts-io implementation Added more strict handling for comma-separated data in URC messages to prevent out-of-bounds reads. --- include/mts/MTS_IO_QuectelRadio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 41c89dc..58e3d25 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -82,8 +82,18 @@ namespace MTS { static uint16_t getQuectelChecksum(const void* data, size_t nBytes); static inline void updateQuectelChecksum(uint16_t& iChecksum, uint16_t iNewFragment); static inline uint16_t bytesToUint16(uint8_t high, uint8_t low); + CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); CODE fumoWaitNewFirmware(UpdateCb& stepCb); + + /// Get value from container by its index, use default value if not found. Non-template version. + const std::string& getByIndex(const std::vector& vector, size_t index, const std::string& defaultValue) { + if (index >= vector.size()) { + return defaultValue; + } else { + return vector[index]; + } + } }; } } -- cgit v1.2.3