Skip to content

Commit

Permalink
coap_block.c: Handle missing Size1 option when using Block1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jan 6, 2025
1 parent bd2c2b0 commit 2475ad0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/coap_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -3148,8 +3148,8 @@ coap_handle_request_put_block(coap_context_t *context,
* complete payload to application and acknowledge this current
* block.
*/
if (!check_all_blocks_in(&lg_srcv->rec_blocks,
(uint32_t)(lg_srcv->total_len + chunk -1)/chunk)) {
if ((total == 0 && block.m) || !check_all_blocks_in(&lg_srcv->rec_blocks,
(uint32_t)(lg_srcv->total_len + chunk -1)/chunk)) {
/* Ask for the next block */
coap_insert_option(response, block_option,
coap_encode_var_safe(buf, sizeof(buf),
Expand All @@ -3169,8 +3169,10 @@ coap_handle_request_put_block(coap_context_t *context,
tmp_pdu->code = COAP_RESPONSE_CODE(231);
coap_send_internal(session, tmp_pdu);
}
coap_update_token(response, lg_srcv->last_token->length, lg_srcv->last_token->s);
coap_update_token(pdu, lg_srcv->last_token->length, lg_srcv->last_token->s);
if (lg_srcv->last_token) {
coap_update_token(response, lg_srcv->last_token->length, lg_srcv->last_token->s);
coap_update_token(pdu, lg_srcv->last_token->length, lg_srcv->last_token->s);
}
/* Pass the assembled pdu and body to the application */
goto give_app_data;
}
Expand Down

0 comments on commit 2475ad0

Please sign in to comment.