Skip to content

Commit

Permalink
coap_net.c: Fix TCP boundary read condition
Browse files Browse the repository at this point in the history
Increment session->partial_read correctly.
  • Loading branch information
mrdeep1 committed Nov 23, 2024
1 parent 19cef11 commit 1d465b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/coap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,7 @@ coap_read_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now)
p += n;
bytes_read -= n;
if (n == len) {
/* Header now all in */
size_t size = coap_pdu_parse_size(session->proto, session->read_header,
hdr_size + tok_ext_bytes);
if (size > COAP_DEFAULT_MAX_PDU_RX_SIZE) {
Expand Down Expand Up @@ -2364,9 +2365,11 @@ coap_read_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now)
session->partial_read = 0;
}
} else {
session->partial_read += bytes_read;
/* More of the header to go */
session->partial_read += n;
}
} else {
/* Get in first byte of the header */
session->read_header[0] = *p++;
bytes_read -= 1;
if (!coap_pdu_parse_header_size(session->proto,
Expand Down

0 comments on commit 1d465b6

Please sign in to comment.