mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 04:07:47 +00:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user