From af0e3f19fa0306158a8f671104bacbbeb76260fe Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 10 Jul 2018 14:13:16 -0500 Subject: [PATCH] [tlv] change GetSize() return type to uint16_t to avoid overflow (#2870) Credit to OSS-Fuzz. --- src/core/common/tlvs.hpp | 2 +- src/core/meshcop/meshcop_tlvs.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/common/tlvs.hpp b/src/core/common/tlvs.hpp index 264edd2e2..209c497d8 100644 --- a/src/core/common/tlvs.hpp +++ b/src/core/common/tlvs.hpp @@ -104,7 +104,7 @@ public: * @returns The total size include Type, Length, and Value fields. * */ - uint8_t GetSize(void) const { return sizeof(Tlv) + mLength; } + uint16_t GetSize(void) const { return sizeof(Tlv) + mLength; } /** * This method returns a pointer to the Value. diff --git a/src/core/meshcop/meshcop_tlvs.hpp b/src/core/meshcop/meshcop_tlvs.hpp index 07673be78..9259eb0d4 100644 --- a/src/core/meshcop/meshcop_tlvs.hpp +++ b/src/core/meshcop/meshcop_tlvs.hpp @@ -1336,7 +1336,7 @@ public: * @returns The total size of this entry (number of bytes). * */ - uint8_t GetSize(void) const { return sizeof(ChannelMaskEntry) + mMaskLength; } + uint16_t GetSize(void) const { return sizeof(ChannelMaskEntry) + mMaskLength; } /** * This method clears the bit corresponding to @p aChannel in ChannelMask.