summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox/0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch
blob: 18bf5f19e4b91c36c0596b5312512f470eeffbc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From c7e181fdf58c392e06ab805e2c044c3e57d5445a Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Sun, 3 Apr 2022 12:14:33 +0000
Subject: [PATCH] libbb: sockaddr2str: ensure only printable characters are
 returned for the hostname part

CVE: CVE-2022-28391
Upstream-Status: Pending
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 libbb/xconnect.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index eb2871cb1..b5520bb21 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -501,8 +501,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
 	);
 	if (rc)
 		return NULL;
+	/* ensure host contains only printable characters */
 	if (flags & IGNORE_PORT)
-		return xstrdup(host);
+		return xstrdup(printable_string(host));
 #if ENABLE_FEATURE_IPV6
 	if (sa->sa_family == AF_INET6) {
 		if (strchr(host, ':')) /* heh, it's not a resolved hostname */
@@ -513,7 +514,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
 #endif
 	/* For now we don't support anything else, so it has to be INET */
 	/*if (sa->sa_family == AF_INET)*/
-		return xasprintf("%s:%s", host, serv);
+		return xasprintf("%s:%s", printable_string(host), serv);
 	/*return xstrdup(host);*/
 }