Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Fix to cellular MQTT client: capture truncated messages correctly. (#…
Browse files Browse the repository at this point in the history
…1093)

The cellular code to read MQTT messages from the MQTT client in a module is intended to return U_ERROR_COMMON_TRUNCATED if an insufficiently large buffer has been provided by the application to read the message. However, it didn't do this correctly: as indicated in the description of the uAtClientReadBytes() function, the last parameter, "standalone", must be set to true if stop tags are being ignored (which they are in this case since the binary message might contain the stop tag string), otherwise the uAtClientReadBytes() function will search forever for a non-existent stop-tag, leading to an error condition in the uAtClient code, and this error will be reported instead of U_ERROR_COMMON_TRUNCATED.

Our thanks to AntonZyma for spotting this.
  • Loading branch information
RobMeades authored Feb 6, 2024
1 parent 7d91feb commit 928ee28
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cell/src/u_cell_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ static int32_t readMessage(const uCellPrivateInstance_t *pInstance,
uAtClientReadBytes(atHandle, NULL,
// Cast in two stages to keep Lint happy
(size_t) (unsigned) (messageBytesAvailable -
messageBytesRead), false);
messageBytesRead), true);
}
}
// Make sure to wait for the stop tag before
Expand Down

0 comments on commit 928ee28

Please sign in to comment.