]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix" (bug 22542)
authorFlorian Weimer <fweimer@redhat.com>
Mon, 17 Jan 2022 09:21:34 +0000 (10:21 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 4 Oct 2022 08:00:00 +0000 (08:00 +0000)
Processing an overlong pathname in the sunrpc clnt_create function
results in a stack-based buffer overflow.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 226b46770c82899b555986583294b049c6ec9b40)

NEWS
sunrpc/clnt_gen.c

diff --git a/NEWS b/NEWS
index f087aff61eaf7b615973e8cca98ac1e19220cedc..53ca17db43bc8f3afa66e4fddd3caa110993be90 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,9 +38,14 @@ Security related changes:
   parameter number when processing the expansion resulting in a crash.
   Reported by Philippe Antoine.
 
+  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:
 
   [20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT
+  [22542] CVE-2022-23219: Buffer overflow in sunrpc clnt_create for "unix"
   [24973] locale: iconv encounters segmentation fault when converting
     0x00 0xfe in EUC-KR to UTF-8 (CVE-2019-25013)
   [25399] string: undefined reference to `__warn_memset_zero_len' when
index 13ced8994e49d4ee744a35c3ac4bd840f5d0abb5..b44357cd88e60599b82635618229109fe91855a0 100644 (file)
@@ -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)