mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 12:40:05 +00:00
[network-diagnostic] limit number of entries in Child Table TLV (#4163)
This commit fixes Thread Certification Test Case Router_5_7_3 where Child Table TLV was damaged. This commit also ensures that only Base TLV format is used. The bug was introduced introduced in d796b0.
This commit is contained in:
committed by
Jonathan Hui
parent
4dc58da927
commit
0e489b07e2
@@ -58,6 +58,15 @@ OT_TOOL_PACKED_BEGIN
|
||||
class Tlv
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Length values.
|
||||
*
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kBaseTlvMaxLength = 254, ///< The maximum length of the Base TLV format.
|
||||
};
|
||||
|
||||
/**
|
||||
* This method returns the Type value.
|
||||
*
|
||||
|
||||
@@ -233,9 +233,13 @@ otError NetworkDiagnostic::AppendChildTable(Message &aMessage)
|
||||
|
||||
count = Get<ChildTable>().GetNumChildren(ChildTable::kInStateValid);
|
||||
|
||||
if (count > (CHAR_BIT * sizeof(uint8_t) / sizeof(ChildTableEntry)))
|
||||
// The length of the Child Table TLV may exceed the outgoing link's MTU (1280B).
|
||||
// As a workaround we limit the number of entries in the Child Table TLV,
|
||||
// also to avoid using extended TLV format. The issue is processed by the
|
||||
// Thread Group (SPEC-894).
|
||||
if (count > (Tlv::kBaseTlvMaxLength / sizeof(ChildTableEntry)))
|
||||
{
|
||||
count = CHAR_BIT * sizeof(uint8_t) / sizeof(ChildTableEntry);
|
||||
count = Tlv::kBaseTlvMaxLength / sizeof(ChildTableEntry);
|
||||
}
|
||||
|
||||
tlv.SetLength(static_cast<uint8_t>(count * sizeof(ChildTableEntry)));
|
||||
@@ -244,6 +248,8 @@ otError NetworkDiagnostic::AppendChildTable(Message &aMessage)
|
||||
|
||||
for (ChildTable::Iterator iter(GetInstance(), ChildTable::kInStateValid); !iter.IsDone(); iter++)
|
||||
{
|
||||
VerifyOrExit(count--);
|
||||
|
||||
Child &child = *iter.GetChild();
|
||||
|
||||
timeout = 0;
|
||||
|
||||
Reference in New Issue
Block a user