summaryrefslogtreecommitdiff
path: root/CVE-2022-23219-Buffer-overflow-in-sunrpc-clnt_create.patch
blob: f5b048847d9d24d0da4a7b387846d19253634d62 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 226b46770c82899b555986583294b049c6ec9b40 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Mon, 17 Jan 2022 10:21:34 +0100
Subject: [PATCH] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for
 "unix" (bug 22542)

Processing an overlong pathname in the sunrpc clnt_create function
results in a stack-based buffer overflow.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

---
 NEWS              | 14 ++++++++++++++
 sunrpc/clnt_gen.c | 10 +++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 3c610744..dbe6f086 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,20 @@ See the end for copying conditions.
 
 Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
 using `glibc' in the "product" field.
+
+^L
+Version 2.34.1
+
+Security related changes:
+
+  CVE-2022-23219: Passing an overlong file name to the clnt_create
+  legacy function could result in a stack-based buffer overflow when
+  using the "unix" protocol.  Reported by Martin Sebor.
+
+The following bugs are resolved with this release:
+
+  [22542] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix"
+
 
 Version 2.34
 
diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c
index 13ced899..b44357cd 100644
--- a/sunrpc/clnt_gen.c
+++ b/sunrpc/clnt_gen.c
@@ -57,9 +57,13 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
 
   if (strcmp (proto, "unix") == 0)
     {
-      memset ((char *)&sun, 0, sizeof (sun));
-      sun.sun_family = AF_UNIX;
-      strcpy (sun.sun_path, hostname);
+      if (__sockaddr_un_set (&sun, hostname) < 0)
+	{
+	  struct rpc_createerr *ce = &get_rpc_createerr ();
+	  ce->cf_stat = RPC_SYSTEMERROR;
+	  ce->cf_error.re_errno = errno;
+	  return NULL;
+	}
       sock = RPC_ANYSOCK;
       client = clntunix_create (&sun, prog, vers, &sock, 0, 0);
       if (client == NULL)
-- 
2.27.0