[trel] relax parsing of TXT data entries to allow extra bytes (#11470)

This commit relaxes the parsing of TREL TXT data entries to allow
extra bytes to be present at the end of a value.

Currently, these extra bytes are simply ignored. This change provides
safer forward compatibility, allowing for future additions to the
format of the TXT data entries.
This commit is contained in:
Abtin Keshavarzian
2025-05-06 10:06:44 -07:00
committed by GitHub
parent 19203d3287
commit 2591b58f3c
+2 -2
View File
@@ -269,14 +269,14 @@ Error Interface::ParsePeerInfoTxtData(const Peer::Info &aInfo,
if (StringMatch(entry.mKey, kTxtRecordExtAddressKey))
{
VerifyOrExit(!parsedExtAddress, error = kErrorParse);
VerifyOrExit(entry.mValueLength == sizeof(Mac::ExtAddress), error = kErrorParse);
VerifyOrExit(entry.mValueLength >= sizeof(Mac::ExtAddress), error = kErrorParse);
aExtAddress.Set(entry.mValue);
parsedExtAddress = true;
}
else if (StringMatch(entry.mKey, kTxtRecordExtPanIdKey))
{
VerifyOrExit(!parsedExtPanId, error = kErrorParse);
VerifyOrExit(entry.mValueLength == sizeof(MeshCoP::ExtendedPanId), error = kErrorParse);
VerifyOrExit(entry.mValueLength >= sizeof(MeshCoP::ExtendedPanId), error = kErrorParse);
memcpy(aExtPanId.m8, entry.mValue, sizeof(MeshCoP::ExtendedPanId));
parsedExtPanId = true;
}