Skip to content

Commit

Permalink
Merge pull request #20855 from benpicco/coap_block_finish-fix
Browse files Browse the repository at this point in the history
nanocoap: always write at least 1 byte in coap_block2_finish()
  • Loading branch information
maribu committed Sep 12, 2024
2 parents 24ad7e7 + 66fe083 commit 1fa7db2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sys/net/application_layer/nanocoap/nanocoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,11 @@ bool coap_block_finish(coap_block_slicer_t *slicer, uint16_t option)
uint32_t blkopt = _slicer2blkopt(slicer, more);
size_t olen = _encode_uint(&blkopt);

/* ensure that we overwrite the dummy value set by coap_block2_init() */
if (!olen) {
olen = 1;
}

coap_put_option(slicer->opt, option - delta, option, (uint8_t *)&blkopt, olen);
return more;
}
Expand Down

0 comments on commit 1fa7db2

Please sign in to comment.