summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dhcpd
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2019-06-28 13:32:41 +0000
committerderaadt <deraadt@openbsd.org>2019-06-28 13:32:41 +0000
commitdf69c215c7c66baf660f3f65414fd34796c96152 (patch)
tree0255639162b24c4a2f761a274e32b69c2256fd45 /usr.sbin/dhcpd
parentminiroot prototype disklabels should attempt to contain accurate (diff)
downloadwireguard-openbsd-df69c215c7c66baf660f3f65414fd34796c96152.tar.xz
wireguard-openbsd-df69c215c7c66baf660f3f65414fd34796c96152.zip
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
Diffstat (limited to 'usr.sbin/dhcpd')
-rw-r--r--usr.sbin/dhcpd/pfutils.c8
-rw-r--r--usr.sbin/dhcpd/udpsock.c10
2 files changed, 9 insertions, 9 deletions
diff --git a/usr.sbin/dhcpd/pfutils.c b/usr.sbin/dhcpd/pfutils.c
index 091f372d5f5..48db8c6faa8 100644
--- a/usr.sbin/dhcpd/pfutils.c
+++ b/usr.sbin/dhcpd/pfutils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfutils.c,v 1.19 2018/12/07 12:52:47 henning Exp $ */
+/* $OpenBSD: pfutils.c,v 1.20 2019/06/28 13:32:47 deraadt Exp $ */
/*
* Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org>
*
@@ -154,7 +154,7 @@ pf_change_table(int fd, int op, struct in_addr ip, char *table)
addr.pfra_af = AF_INET;
addr.pfra_net = 32;
- if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) &&
+ if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) == -1 &&
errno != ESRCH) {
log_warn( "DIOCR%sADDRS on table %s", op ? "ADD" : "DEL",
table);
@@ -178,7 +178,7 @@ pf_kill_state(int fd, struct in_addr ip)
sizeof(psk.psk_src.addr.v.a.addr));
memset(&psk.psk_src.addr.v.a.mask, 0xff,
sizeof(psk.psk_src.addr.v.a.mask));
- if (ioctl(fd, DIOCKILLSTATES, &psk)) {
+ if (ioctl(fd, DIOCKILLSTATES, &psk) == -1) {
log_warn("DIOCKILLSTATES failed");
}
@@ -188,7 +188,7 @@ pf_kill_state(int fd, struct in_addr ip)
sizeof(psk.psk_dst.addr.v.a.addr));
memset(&psk.psk_dst.addr.v.a.mask, 0xff,
sizeof(psk.psk_dst.addr.v.a.mask));
- if (ioctl(fd, DIOCKILLSTATES, &psk)) {
+ if (ioctl(fd, DIOCKILLSTATES, &psk) == -1) {
log_warn("DIOCKILLSTATES failed");
}
}
diff --git a/usr.sbin/dhcpd/udpsock.c b/usr.sbin/dhcpd/udpsock.c
index 6f50d4712b2..ff7e4a32bdc 100644
--- a/usr.sbin/dhcpd/udpsock.c
+++ b/usr.sbin/dhcpd/udpsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udpsock.c,v 1.10 2017/02/13 22:33:39 krw Exp $ */
+/* $OpenBSD: udpsock.c,v 1.11 2019/06/28 13:32:47 deraadt Exp $ */
/*
* Copyright (c) 2014 YASUOKA Masahiko <yasuoka@openbsd.org>
@@ -58,7 +58,7 @@ udpsock_startup(struct in_addr bindaddr)
fatal("could not create udpsock");
memset(&sin4, 0, sizeof(sin4));
- if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
fatal("creating a socket failed for udp");
onoff = 1;
@@ -115,7 +115,7 @@ udpsock_handler(struct protocol *protocol)
m.msg_controllen = sizeof(cbuf);
memset(&iface, 0, sizeof(iface));
- if ((len = recvmsg(udpsock->sock, &m, 0)) < 0) {
+ if ((len = recvmsg(udpsock->sock, &m, 0)) == -1) {
log_warn("receiving a DHCP message failed");
return;
}
@@ -137,12 +137,12 @@ udpsock_handler(struct protocol *protocol)
}
if_indextoname(sdl->sdl_index, ifname);
- if ((sockio = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ if ((sockio = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
log_warn("socket creation failed");
return;
}
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
- if (ioctl(sockio, SIOCGIFADDR, &ifr, sizeof(ifr)) != 0) {
+ if (ioctl(sockio, SIOCGIFADDR, &ifr, sizeof(ifr)) == -1) {
log_warn("Failed to get address for %s", ifname);
close(sockio);
return;