Skip to content

Commit

Permalink
fixup! nanocoap: add coap_build_reply_header()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jan 23, 2024
1 parent 3d25404 commit 8930092
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sys/net/application_layer/nanocoap/nanocoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,14 @@ ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
}
*bufpos++ = COAP_PAYLOAD_MARKER;
*payload = bufpos;
*payload_len_max = len - (bufpos - (uint8_t *)buf);
hdr_len += bufpos - (uint8_t *)buf;
*payload_len_max = len - hdr_len;
}

return bufpos - (uint8_t *)buf;
/* with the nanoCoAP API we can't detect the overflow before it happens */
assert(hdr_len <= len);

return hdr_len;
}

ssize_t coap_reply_simple(coap_pkt_t *pkt,
Expand Down

0 comments on commit 8930092

Please sign in to comment.