Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/protocol/dte_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ class DTEDecoder {
char format[32];
int written;

snprintf(format, sizeof(format), "%%%zu", s.size());
snprintf(format, sizeof(format), "%%%u", s.size());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So an update... this is what ended up being the issue with the ble interface.
The %zu and %zX is for a size_t format specifier and gives unexpected results.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out that these lines caused an error 4 - DTE_PROTOCOL_BAD_FORMAT and an error 5 - DTE_PROTOCOL_PAYLOAD_LENGTH_MISMATCH

strncat(format, fmt + 1, sizeof(format) - strlen(format) - 1);
strncat(format, "%n", sizeof(format) - strlen(format) - 1);

Expand Down Expand Up @@ -1388,7 +1388,7 @@ class DTEDecoder {
return false;

size_t length;
sscanf(&str[str_pos], "%3zX", &length);
sscanf(&str[str_pos], "%3X", &length);
str_pos += size_of_length_field;

// Check the command deliminator //
Expand Down