sizeof(struct sockaddr_un), so do the simple, portable thing.
Also convert some strncpy() to strlcpy()
ok deraadt@
-/* $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
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;
-/* $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
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)
-/* $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 $ */
/*
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;
-/* $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 $ */
/*
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);
}
-/* $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
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) {
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);