[logging] fix BeaconPayload::ToInfoString() print of network name (#3771)

`BeaconPayload::GetNetworkName()` does not return a NULL-terminated string.

This commit fixes `BeaconPayload::ToInfoString()` to pass a NULL-terminated
string to the string formatter.
This commit is contained in:
Jonathan Hui
2019-04-18 13:42:33 -07:00
committed by GitHub
parent a09d8da38c
commit 5adac06d08
+4 -1
View File
@@ -1112,9 +1112,12 @@ Frame::InfoString Frame::ToInfoString(void) const
BeaconPayload::InfoString BeaconPayload::ToInfoString(void) const
{
const uint8_t *xpanid = GetExtendedPanId();
otNetworkName networkname;
strlcpy(networkname.m8, GetNetworkName(), sizeof(networkname.m8));
return InfoString("name:%s, xpanid:%02x%02x%02x%02x%02x%02x%02x%02x, id:%d ver:%d, joinable:%s, native:%s",
GetNetworkName(), xpanid[0], xpanid[1], xpanid[2], xpanid[3], xpanid[4], xpanid[5], xpanid[6],
networkname.m8, xpanid[0], xpanid[1], xpanid[2], xpanid[3], xpanid[4], xpanid[5], xpanid[6],
xpanid[7], GetProtocolId(), GetProtocolVersion(), IsJoiningPermitted() ? "yes" : "no",
IsNative() ? "yes" : "no");
}