[network-data] add length validation to Server TLV (#2532)

Credit to OSS-Fuzz.
This commit is contained in:
Jonathan Hui
2018-02-05 17:06:36 +00:00
committed by GitHub
parent d0c983f0a4
commit 9ec07205cc
2 changed files with 12 additions and 0 deletions
@@ -543,6 +543,7 @@ otError Leader::RlocLookup(uint16_t aRloc16, bool &aIn, bool &aStable, uint8_t *
{
case NetworkDataTlv::kTypeServer:
server = static_cast<ServerTlv *>(subCur);
VerifyOrExit(server->IsValid(), error = OT_ERROR_PARSE);
if (server->GetServer16() == aRloc16)
{
+11
View File
@@ -923,6 +923,17 @@ public:
*/
void Init(void) { NetworkDataTlv::Init(); SetType(kTypeServer); SetLength(sizeof(*this) - sizeof(NetworkDataTlv)); }
/**
* This method indicates whether or not the TLV appears to be well-formed.
*
* @retval TRUE If the TLV appears to be well-formed.
* @retval FALSE If the TLV does not appear to be well-formed.
*
*/
bool IsValid(void) const {
return GetLength() >= (sizeof(*this) - sizeof(NetworkDataTlv));
}
/**
* This method returns the S_server_16 value.
*