From 610c14c2474e1f3445abe122cf19d10783c4dfde Mon Sep 17 00:00:00 2001 From: Andrea Gilardoni Date: Wed, 24 Jan 2024 15:22:21 +0100 Subject: [PATCH] fixing counter overflow in tcp send --- libraries/lwIpWrapper/src/lwipClient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/lwIpWrapper/src/lwipClient.cpp b/libraries/lwIpWrapper/src/lwipClient.cpp index 019ea459..9aeb99cd 100644 --- a/libraries/lwIpWrapper/src/lwipClient.cpp +++ b/libraries/lwIpWrapper/src/lwipClient.cpp @@ -265,7 +265,7 @@ size_t lwipClient::write(const uint8_t* buffer, size_t size) { arduino::lock(); uint8_t* buffer_cursor = (uint8_t*)buffer; - uint8_t bytes_to_send = 0; + uint16_t bytes_to_send = 0; do { bytes_to_send = min(size - (buffer - buffer_cursor), tcp_sndbuf(this->tcp_info->pcb)); @@ -282,7 +282,7 @@ size_t lwipClient::write(const uint8_t* buffer, size_t size) { } else if(res == ERR_MEM) { // FIXME handle this: we get into this case only if the sent data cannot be put in the send queue } - } while(buffer_cursor < buffer + size); + } while(buffer_cursor - buffer < size); tcp_output(this->tcp_info->pcb);