[PATCH] dnsproxy: Fix NULL/empty lookup causing potential crash

Praveen Kumar <[email protected]> Thu, 24 Apr 2025 11:39:29 +0000
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
In ConnMan through 1.44, the lookup string in ns_resolv in dnsproxy.c
can be NULL or an empty string when the TC (Truncated) bit is set in
a DNS response. This allows attackers to cause a denial of service
(application crash) or possibly execute arbitrary code, because those
lookup values lead to incorrect length calculations and incorrect
memcpy operations.

This patch includes a check to make sure loookup value is valid before
using it. This helps avoid unexpected value when the input is empty or
incorrect.

Fixes: CVE-2025-32743

Signed-off-by: Praveen Kumar <[email protected]>
---
 src/dnsproxy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index f28a5d75..15917eda 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1686,6 +1686,10 @@ static int ns_resolv(struct server_data *server, struct request_data *req,
 {
 	int sk = -1;
 	const char *lookup = (const char *)name;
+
+	if (!lookup || strlen(lookup) == 0)
+		return -EINVAL;
+
 	int err = ns_try_resolv_from_cache(req, request, lookup);
 
 	if (err > 0)
-- 
2.40.0