From 0db06ebc77246d112c19f9b0f48fe9fd9bf15445 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 6 May 2026 17:51:17 -0700 Subject: [PATCH] [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. --- src/core/thread/network_data_tlvs.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/thread/network_data_tlvs.hpp b/src/core/thread/network_data_tlvs.hpp index 273c89550..b5ac530c4 100644 --- a/src/core/thread/network_data_tlvs.hpp +++ b/src/core/thread/network_data_tlvs.hpp @@ -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.