Bound payload.bytes prints by payload.size (#11032)
decoded.payload.bytes is a 233-byte protobuf field that is not NUL-terminated. Printing it with a plain "%s" reads until a NUL, which for a full-length payload with no NUL runs past the field. Use "%.*s" with payload.size, matching the write form already used a few lines up in SerialModule. Live sites: RangeTestModule appendFile, SerialModule text output. The same fix is applied to the commented-out debug lines in RangeTestModule and Router so the pattern is consistent if they are re-enabled.
This commit is contained in:
co-authored by
GitHub
parent
88f20d349a
commit
8ebdae9921
+1
-1
@@ -753,7 +753,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
|
||||
LOG_DEBUG("Original length - %d ", p->decoded.payload.size);
|
||||
LOG_DEBUG("Compressed length - %d ", compressed_len);
|
||||
LOG_DEBUG("Original message - %s ", p->decoded.payload.bytes);
|
||||
LOG_DEBUG("Original message - %.*s ", (int)p->decoded.payload.size, p->decoded.payload.bytes);
|
||||
|
||||
// If the compressed length is greater than or equal to the original size, don't use the compressed form
|
||||
if (compressed_len >= p->decoded.payload.size) {
|
||||
|
||||
Reference in New Issue
Block a user