diff options
author | Florian Weimer <fweimer@redhat.com> | 2022-01-17 10:21:34 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2022-01-18 07:46:02 +0100 |
commit | 4653cd9e3669ff0a49908397e6f2a2eb8e572fdf (patch) | |
tree | fb245d1fb91719c60fb41ddf971e0143594bd669 /sunrpc | |
parent | f10e992e8d6c61f915c711f7bcc491ad2f10b06c (diff) | |
download | glibc-4653cd9e3669ff0a49908397e6f2a2eb8e572fdf.tar.gz |
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>
(cherry picked from commit 226b46770c82899b555986583294b049c6ec9b40)
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/clnt_gen.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c index 13ced8994e..b44357cd88 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) |