summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/apm/apm.c7
-rw-r--r--usr.sbin/apmd/apmd.c7
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c4
-rw-r--r--usr.sbin/lpr/lpd/lpd.c4
-rw-r--r--usr.sbin/syslogd/syslogd.c7
5 files changed, 12 insertions, 17 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 551a083f875..7f2aa7a860a 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.29 2015/01/16 06:40:15 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.30 2015/10/11 20:23:49 guenther Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -130,9 +130,8 @@ open_socket(const char *sockname)
err(1, "cannot create local socket");
s_un.sun_family = AF_UNIX;
- strncpy(s_un.sun_path, sockname, sizeof(s_un.sun_path));
- s_un.sun_len = SUN_LEN(&s_un);
- if (connect(sock, (struct sockaddr *)&s_un, s_un.sun_len) == -1) {
+ strlcpy(s_un.sun_path, sockname, sizeof(s_un.sun_path));
+ if (connect(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
errr = errno;
close(sock);
errno = errr;
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index e0cf93eb5ae..420450ef538 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.76 2015/08/28 16:13:58 tedu Exp $ */
+/* $OpenBSD: apmd.c,v 1.77 2015/10/11 20:23:49 guenther Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -212,14 +212,13 @@ bind_socket(const char *sockname)
error("cannot create local socket", NULL);
s_un.sun_family = AF_UNIX;
- strncpy(s_un.sun_path, sockname, sizeof(s_un.sun_path));
- s_un.sun_len = SUN_LEN(&s_un);
+ strlcpy(s_un.sun_path, sockname, sizeof(s_un.sun_path));
/* remove it if present, we're moving in */
(void) remove(sockname);
old_umask = umask(077);
- if (bind(sock, (struct sockaddr *)&s_un, s_un.sun_len) == -1)
+ if (bind(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == -1)
error("cannot connect to APM socket", NULL);
umask(old_umask);
if (chmod(sockname, 0660) == -1 || chown(sockname, 0, 0) == -1)
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 84988f3e3ed..ca4acf98922 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: startdaemon.c,v 1.15 2015/01/16 06:40:17 deraadt Exp $ */
+/* $OpenBSD: startdaemon.c,v 1.16 2015/10/11 20:23:49 guenther Exp $ */
/* $NetBSD: startdaemon.c,v 1.10 1998/07/18 05:04:39 lukem Exp $ */
/*
@@ -66,7 +66,7 @@ startdaemon(char *printer)
strlcpy(un.sun_path, _PATH_SOCKETNAME, sizeof(un.sun_path));
siginterrupt(SIGINT, 1);
PRIV_START;
- if (connect(s, (struct sockaddr *)&un, SUN_LEN(&un)) < 0) {
+ if (connect(s, (struct sockaddr *)&un, sizeof(un)) < 0) {
int saved_errno = errno;
if (errno == EINTR && gotintr) {
PRIV_END;
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 033ae8f2630..0a778fc2604 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.59 2015/09/29 02:37:29 millert Exp $ */
+/* $OpenBSD: lpd.c,v 1.60 2015/10/11 20:23:49 guenther Exp $ */
/* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */
/*
@@ -280,7 +280,7 @@ main(int argc, char **argv)
un.sun_family = AF_LOCAL;
strlcpy(un.sun_path, _PATH_SOCKETNAME, sizeof(un.sun_path));
PRIV_START;
- if (bind(funix, (struct sockaddr *)&un, SUN_LEN(&un)) < 0) {
+ if (bind(funix, (struct sockaddr *)&un, sizeof(un)) < 0) {
syslog(LOG_ERR, "ubind: %m");
exit(1);
}
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index a9364ebb317..4513772ea41 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.195 2015/10/10 20:35:01 deraadt Exp $ */
+/* $OpenBSD: syslogd.c,v 1.196 2015/10/11 20:23:49 guenther Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -491,9 +491,6 @@ main(int argc, char *argv[])
die(0);
}
-#ifndef SUN_LEN
-#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2)
-#endif
for (i = 0; i < nunix; i++) {
fd_unix[i] = unix_socket(path_unix[i], SOCK_DGRAM, 0666);
if (fd_unix[i] == -1) {
@@ -2813,7 +2810,7 @@ unix_socket(char *path, int type, mode_t mode)
old_umask = umask(0177);
unlink(path);
- if (bind(fd, (struct sockaddr *)&s_un, SUN_LEN(&s_un)) == -1) {
+ if (bind(fd, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
snprintf(ebuf, sizeof(ebuf), "cannot bind %s", path);
logerror(ebuf);
umask(old_umask);