git: 1253835121cb - main - inetd: fix unix sockaddr's length assignment

Kyle Evans kevans at FreeBSD.org
Fri Feb 12 19:36:57 UTC 2021


The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=1253835121cb38fd93478849e32a4a4c13436fb2

commit 1253835121cb38fd93478849e32a4a4c13436fb2
Author:     Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2021-02-12 19:19:43 +0000
Commit:     Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-02-12 19:36:38 +0000

    inetd: fix unix sockaddr's length assignment
    
    unsz was always exactly '1' here due to an unfortunate mispositioning
    of closing parenthesis. While it's generally irrelevant because bind(2)
    is passed the (accurate) sep->se_ctrladdr_size instead, it's not very
    helpful for anything locally that wants to use it rather than assuming
    that sep->se_ctrladdr_size perfectly fits the end of sun_path.
    
    Just drop unsz entirely and use the result of SUN_LEN() for it.
    
    MFC-after:      3 days
---
 usr.sbin/inetd/inetd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 7ba51c9af593..6c4e26fad5cd 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1624,7 +1624,6 @@ getconfigent(void)
 	int v6bind;
 #endif
 	int i;
-	size_t unsz;
 
 #ifdef IPSEC
 	policy = NULL;
@@ -1852,16 +1851,16 @@ more:
 #define	SUN_PATH_MAXSIZE	sizeof(sep->se_ctrladdr_un.sun_path)
 		memset(&sep->se_ctrladdr, 0, sizeof(sep->se_ctrladdr));
 		sep->se_ctrladdr_un.sun_family = sep->se_family;
-		if ((unsz = strlcpy(sep->se_ctrladdr_un.sun_path,
-		    sep->se_service, SUN_PATH_MAXSIZE) >= SUN_PATH_MAXSIZE)) {
+		if (strlcpy(sep->se_ctrladdr_un.sun_path, sep->se_service,
+		    SUN_PATH_MAXSIZE) >= SUN_PATH_MAXSIZE) {
 			syslog(LOG_ERR,
 			    "domain socket pathname too long for service %s",
 			    sep->se_service);
 			goto more;
 		}
-		sep->se_ctrladdr_un.sun_len = unsz;
 #undef SUN_PATH_MAXSIZE
-		sep->se_ctrladdr_size = SUN_LEN(&sep->se_ctrladdr_un);
+		sep->se_ctrladdr_size = sep->se_ctrladdr_un.sun_len =
+		    SUN_LEN(&sep->se_ctrladdr_un);
 	}
 	arg = sskip(&cp);
 	if (!strncmp(arg, "wait", 4))


More information about the dev-commits-src-main mailing list