Skip to content

Commit d6ab05f

Browse files
net: websocket: Do not output NULL / zero length websocket data
OCPP pongs do not carry payload and cannot be NET_DBG'd without crash. Signed-off-by: Markus Becker <[email protected]>
1 parent 3aef349 commit d6ab05f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/net/lib/websocket/websocket.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ int websocket_send_msg(int ws_sock, const uint8_t *payload, size_t payload_len,
727727
NET_DBG("[%p] Len %zd %s/%d/%s", ctx, payload_len, opcode2str(opcode),
728728
mask, final ? "final" : "more");
729729

730+
if (payload_len == 0 || payload == NULL) {
731+
NET_DBG("DATA len 0 or NULL");
732+
} else {
733+
NET_DBG("DATA %.*s", payload_len, payload);
734+
}
730735
memset(header, 0, sizeof(header));
731736

732737
/* Is this the last packet? */

0 commit comments

Comments
 (0)