Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumpuser In unix_parse(), always allocate memory for ...



details:   https://anonhg.NetBSD.org/src/rev/1a97d7cb9e5c
branches:  trunk
changeset: 1026790:1a97d7cb9e5c
user:      gson <gson%NetBSD.org@localhost>
date:      Tue Dec 07 10:39:33 2021 +0000

description:
In unix_parse(), always allocate memory for the entire struct sockaddr_un
and not just the part used by the present pathname, because the entire
struct will be passed to bind() and an EFAULT can result if not all of
it is a valid allocation.  Fixes PR kern/56533.

diffstat:

 lib/librumpuser/sp_common.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (25 lines):

diff -r 972b0949a722 -r 1a97d7cb9e5c lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c       Tue Dec 07 08:04:10 2021 +0000
+++ b/lib/librumpuser/sp_common.c       Tue Dec 07 10:39:33 2021 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: sp_common.c,v 1.42 2020/06/13 16:51:59 kamil Exp $    */
+/*      $NetBSD: sp_common.c,v 1.43 2021/12/07 10:39:33 gson Exp $     */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -670,12 +670,10 @@
                }
        }
        strcat(s_un.sun_path, addr);
-#if defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
+#if !(defined(__linux__) || defined(__sun__) || defined(__CYGWIN__))
+       s_un.sun_len = SUN_LEN(&s_un);
+#endif
        slen = sizeof(s_un);
-#else
-       s_un.sun_len = SUN_LEN(&s_un);
-       slen = s_un.sun_len+1; /* get the 0 too */
-#endif
 
        if (savepath && *parsedurl == '\0') {
                snprintf(parsedurl, sizeof(parsedurl),



Home | Main Index | Thread Index | Old Index