diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-02-08 13:32:25 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-02-08 13:32:25 +0000 |
commit | 0ae251368e20313e60a071549d04cb246ecf9d0a (patch) | |
tree | 9a87bef487bdb3c936993cb48cd01ef6a23251c3 /usr.sbin/hoststated/control.c | |
parent | 352d740dd85eb470c920da7405b235e0849a6c80 (diff) |
carefully check some return values and make lint happier. never pass
any truncated strings (table names/anchors/tags/...) to pf and the
kernel.
ok pyr@
Diffstat (limited to 'usr.sbin/hoststated/control.c')
-rw-r--r-- | usr.sbin/hoststated/control.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/hoststated/control.c b/usr.sbin/hoststated/control.c index 20e1cc04ff5..bfd318f45ea 100644 --- a/usr.sbin/hoststated/control.c +++ b/usr.sbin/hoststated/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.12 2007/02/07 13:39:58 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.13 2007/02/08 13:32:24 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -56,7 +56,12 @@ control_init(void) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, HOSTSTATED_SOCKET, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, HOSTSTATED_SOCKET, + sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) { + log_warn("control_init: %s name too long", HOSTSTATED_SOCKET); + close(fd); + return (-1); + } if (unlink(HOSTSTATED_SOCKET) == -1) if (errno != ENOENT) { @@ -69,10 +74,10 @@ control_init(void) if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { log_warn("control_init: bind: %s", HOSTSTATED_SOCKET); close(fd); - umask(old_umask); + (void)umask(old_umask); return (-1); } - umask(old_umask); + (void)umask(old_umask); if (chmod(HOSTSTATED_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) { log_warn("control_init: chmod"); @@ -106,8 +111,7 @@ control_listen(void) void control_cleanup(void) { - - unlink(HOSTSTATED_SOCKET); + (void)unlink(HOSTSTATED_SOCKET); } /* ARGSUSED */ |