From 27e07b2943ca4ab3f8e4910466231f822299421d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 13 Mar 2025 23:28:42 +0100 Subject: [PATCH] doh: remove wrong but unreachable exit path from doh_decode_rdata_name The condition could not happen, as the function is only called from a single place where the caller already made sure it can't happen. This change still removes the flawed logic. Reported-by: Ronald Crane Closes #16710 --- lib/doh.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/doh.c b/lib/doh.c index 6b37727c38..dbeb6d71a3 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -1018,19 +1018,15 @@ static CURLcode doh_decode_rdata_name(unsigned char **buf, size_t *remaining, char **dnsname) { unsigned char *cp = NULL; - int rem = 0; + size_t rem = 0; unsigned char clen = 0; /* chunk len */ struct dynbuf thename; DEBUGASSERT(buf && remaining && dnsname); - if(!buf || !remaining || !dnsname) + if(!buf || !remaining || !dnsname || !*remaining) return CURLE_OUT_OF_MEMORY; - rem = (int)*remaining; - if(rem <= 0) { - Curl_dyn_free(&thename); - return CURLE_OUT_OF_MEMORY; - } Curl_dyn_init(&thename, CURL_MAXLEN_host_name); + rem = *remaining; cp = *buf; clen = *cp++; if(clen == 0) { -- 2.47.2