[tlv] fix ReadStringTlv() (#8897)

This commit fixes `ReadStringTlv()` avoid returning an extra
character and making sure `\0` is added at the correct index
at `[length]`.
This commit is contained in:
Abtin Keshavarzian
2023-03-22 18:48:14 -07:00
committed by GitHub
parent a4f1c7afa7
commit a43484ed44
+1 -1
View File
@@ -193,7 +193,7 @@ Error Tlv::ReadStringTlv(const Message &aMessage, uint16_t aOffset, uint8_t aMax
length = Min(info.mLength, static_cast<uint16_t>(aMaxStringLength));
aMessage.ReadBytes(info.mValueOffset, aValue, length);
aValue[length + 1] = '\0';
aValue[length] = '\0';
exit:
return error;