[network-data] reject Context ID 0 in ContextTlv::IsValid() (#13069)

This commit updates the `ContextTlv::IsValid()` method to reject
Context TLVs that specify a Context ID of zero.

According to the Thread specification, Context ID 0 is reserved for
the Mesh-Local Prefix and should not be distributed in the Network Data.
Adding this check ensures that such invalid TLVs are correctly
identified as malformed and dropped during Network Data processing.
This commit is contained in:
Abtin Keshavarzian
2026-05-06 17:51:17 -07:00
committed by GitHub
parent 7b200c79df
commit 0db06ebc77
+4 -1
View File
@@ -1128,7 +1128,10 @@ public:
* @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); }
bool IsValid(void) const
{
return (GetLength() >= sizeof(*this) - sizeof(NetworkDataTlv)) && (GetContextId() != 0);
}
/**
* Indicates whether or not the Compress flag is set.