From ae515cd95a6f96167be12f40f542f2cbbdaac146 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Thu, 27 Aug 2026 14:05:59 +0000 Subject: [PATCH] allocator_thread: fix asserts on invalid hostname lengths closes #621 --- src/allocator_thread.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/allocator_thread.c b/src/allocator_thread.c index 66cf7f6..2d6fbab 100644 --- a/src/allocator_thread.c +++ b/src/allocator_thread.c @@ -246,7 +246,7 @@ static void* threadfunc(void* x) { char *host = string_from_internal_ip(msg.m.ip); if(host) { size_t l = strlen(host); - assert(l+1 < MSG_LEN_MAX); + assert(l+1 <= MSG_LEN_MAX); memcpy(msg.m.host, host, l + 1); msg.h.datalen = l + 1; } else { @@ -268,9 +268,10 @@ static void* threadfunc(void* x) { ip_type4 at_get_ip_for_host(char* host, size_t len) { ip_type4 readbuf; + struct at_msg msg = {.h.msgtype = ATM_GETIP }; MUTEX_LOCK(internal_ips_lock); - if(len > MSG_LEN_MAX) goto inv; - struct at_msg msg = {.h.msgtype = ATM_GETIP, .h.datalen = len + 1 }; + if(len >= MSG_LEN_MAX) goto inv; + msg.h.datalen = len + 1; memcpy(msg.m.host, host, len+1); if(sendmessage(ATD_SERVER, &msg) && getmessage(ATD_CLIENT, &msg)) readbuf = msg.m.ip;