[network-data] add check for prefix length (#3626)

This commit is contained in:
Jonathan Hui
2019-02-25 18:36:36 -08:00
committed by GitHub
parent d912393c7f
commit a3548df579
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ inline uint32_t Reverse32(uint32_t v)
return v;
}
#define BitVectorBytes(x) (((x) + (CHAR_BIT - 1)) / CHAR_BIT)
#define BitVectorBytes(x) static_cast<uint8_t>(((x) + (CHAR_BIT - 1)) / CHAR_BIT)
namespace BigEndian {
+2 -1
View File
@@ -345,7 +345,8 @@ public:
bool IsValid(void) const
{
return ((GetLength() >= sizeof(*this) - sizeof(NetworkDataTlv)) &&
(GetLength() >= BitVectorBytes(mPrefixLength) + sizeof(*this) - sizeof(NetworkDataTlv)));
(GetLength() >= BitVectorBytes(mPrefixLength) + sizeof(*this) - sizeof(NetworkDataTlv)) &&
(BitVectorBytes(mPrefixLength) <= sizeof(Ip6::Address)));
}
/**