Skip to content

Commit

Permalink
net: mqtt: Fix NULL pointer dereference in logs
Browse files Browse the repository at this point in the history
MQTT packet_length_encode function accepts NULL buf argument, therefore
it cannot be dereferenced without a check.

Signed-off-by: Robert Lubos <[email protected]>
  • Loading branch information
rlubos authored and nashif committed Nov 28, 2018
1 parent a26db60 commit b5f9771
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion subsys/net/lib/mqtt_sock/mqtt_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ static u8_t packet_length_encode(u32_t length, struct buf_ctx *buf)
{
u8_t encoded_bytes = 0;

MQTT_TRC(">> length:0x%08x cur:%p, end:%p", length, buf->cur, buf->end);
MQTT_TRC(">> length:0x%08x cur:%p, end:%p", length,
(buf == NULL) ? 0 : buf->cur, (buf == NULL) ? 0 : buf->end);

do {
encoded_bytes++;
Expand Down

0 comments on commit b5f9771

Please sign in to comment.