summaryrefslogtreecommitdiff
path: root/usr.sbin/apmd/apmd.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-10-11 20:23:50 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-10-11 20:23:50 +0000
commit28b23bc49f2cfdf5f33300636bf3a1e27cedc637 (patch)
tree530be54585dba4d94b79ac7f53d4a1ad0a435caa /usr.sbin/apmd/apmd.c
parent45f71ffce4de585efba855a1f33f1565ba39ad46 (diff)
Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept
sizeof(struct sockaddr_un), so do the simple, portable thing. Also convert some strncpy() to strlcpy() ok deraadt@
Diffstat (limited to 'usr.sbin/apmd/apmd.c')
-rw-r--r--usr.sbin/apmd/apmd.c7
1 files changed, 3 insertions, 4 deletions
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)