From c4ce40347fa8c790bc7bb59c466f6840023d6d93 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sun, 23 Apr 2023 14:20:16 +0100 Subject: [PATCH] coap_pdu_duplicate: Revert and fix previous change --- src/block.c | 6 +++--- src/pdu.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/block.c b/src/block.c index 5828e86f..812f7833 100644 --- a/src/block.c +++ b/src/block.c @@ -135,7 +135,7 @@ setup_block_b(coap_session_t *session, coap_pdu_t *pdu, coap_block_b_t *block, if (avail < 16) { /* bad luck, this is the smallest block size */ coap_log_debug( - "not enough space, even the smallest block does not fit\n"); + "not enough space, even the smallest block does not fit (1)\n"); return 0; } new_blk_size = coap_flsll((long long)avail) - 5; @@ -669,7 +669,7 @@ coap_add_data_large_internal(coap_session_t *session, if (avail < 16 && ((ssize_t)length > avail || have_block_defined)) { /* bad luck, this is the smallest block size */ coap_log_debug( - "not enough space, even the smallest block does not fit\n"); + "not enough space, even the smallest block does not fit (2)\n"); goto fail; } @@ -838,7 +838,7 @@ coap_add_data_large_internal(coap_session_t *session, /* chunk size change down */ if (avail < 16) { coap_log_warn( - "not enough space, even the smallest block does not fit\n"); + "not enough space, even the smallest block does not fit (3)\n"); goto fail; } blk_size = coap_flsll((long long)avail) - 4 - 1; diff --git a/src/pdu.c b/src/pdu.c index 69f42d0c..ca0700e1 100644 --- a/src/pdu.c +++ b/src/pdu.c @@ -189,7 +189,8 @@ coap_pdu_duplicate(const coap_pdu_t *old_pdu, session->doing_first = 0; pdu = coap_pdu_init(old_pdu->type, old_pdu->code, coap_new_message_id(session), - 0); + max(old_pdu->max_size, + coap_session_max_pdu_size(session))); /* Restore any pending waits */ session->doing_first = doing_first; if (pdu == NULL)