From 2d11e9e02b88b535fc6e9dc4e383caca640f45e0 Mon Sep 17 00:00:00 2001 From: SciLor Date: Wed, 13 Nov 2024 19:55:53 +0000 Subject: [PATCH] possible fix for wrong memchr / strchar socketReceive --- src/platform/platform_linux.c | 6 +++--- src/platform/platform_windows.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/platform/platform_linux.c b/src/platform/platform_linux.c index 2cab3dd2..45d13579 100644 --- a/src/platform/platform_linux.c +++ b/src/platform/platform_linux.c @@ -281,7 +281,7 @@ error_t socketReceive(Socket *socket, void *data_in, const char *ptr = NULL; /* First, check for the null terminator (0x00) in the buffer */ - const char *null_pos = memchr(buff->buffer, 0x00, buff->buffer_used); + const char *null_pos = memchr(buff->buffer, 0x00, max_size); if (null_pos) { /* If null terminator is found, use strchr up to the null */ @@ -289,9 +289,9 @@ error_t socketReceive(Socket *socket, void *data_in, } else { - TRACE_DEBUG("buffer does not contain null terminator\r\n"); + TRACE_WARNING("buffer does not contain null terminator\r\n"); /* If no null terminator, safely use memchr over the whole buffer */ - ptr = memchr(buff->buffer, flags & 0xFF, buff->buffer_used); + ptr = memchr(buff->buffer, flags & 0xFF, max_size); } if (ptr) diff --git a/src/platform/platform_windows.c b/src/platform/platform_windows.c index 35f91724..4a037a47 100644 --- a/src/platform/platform_windows.c +++ b/src/platform/platform_windows.c @@ -330,7 +330,7 @@ error_t socketReceive(Socket *socket, void *data_in, const char *ptr = NULL; /* First, check for the null terminator (0x00) in the buffer */ - const char *null_pos = memchr(buff->buffer, 0x00, buff->buffer_used); + const char *null_pos = memchr(buff->buffer, 0x00, max_size); if (null_pos) { /* If null terminator is found, use strchr up to the null */ @@ -338,9 +338,9 @@ error_t socketReceive(Socket *socket, void *data_in, } else { - TRACE_DEBUG("buffer does not contain null terminator\r\n"); + TRACE_WARNING("buffer does not contain null terminator\r\n"); /* If no null terminator, safely use memchr over the whole buffer */ - ptr = memchr(buff->buffer, flags & 0xFF, buff->buffer_used); + ptr = memchr(buff->buffer, flags & 0xFF, max_size); } if (ptr)