From d834ae3ca59cf75cd7f26a5201a7223eaa468fbb Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Wed, 16 May 2018 21:36:16 +0200 Subject: [PATCH] dhcpv4: fix error checking in dhcpv4_setup_interface() Signed-off-by: Hans Dedecker --- src/dhcpv4.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dhcpv4.c b/src/dhcpv4.c index b803359..3002c1e 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -113,7 +113,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable) } if (setsockopt(iface->dhcpv4_event.uloop.fd, IPPROTO_IP, IP_PKTINFO, - &val, sizeof(val))) { + &val, sizeof(val)) < 0) { syslog(LOG_ERR, "setsockopt(IP_PKTINFO): %m"); ret = -1; goto out; @@ -121,7 +121,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable) val = IPTOS_PREC_INTERNETCONTROL; if (setsockopt(iface->dhcpv4_event.uloop.fd, IPPROTO_IP, IP_TOS, - &val, sizeof(val))) { + &val, sizeof(val)) < 0) { syslog(LOG_ERR, "setsockopt(IP_TOS): %m"); ret = -1; goto out; @@ -129,20 +129,21 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable) val = IP_PMTUDISC_DONT; if (setsockopt(iface->dhcpv4_event.uloop.fd, IPPROTO_IP, IP_MTU_DISCOVER, - &val, sizeof(val))) { + &val, sizeof(val)) < 0) { syslog(LOG_ERR, "setsockopt(IP_MTU_DISCOVER): %m"); ret = -1; goto out; } if (setsockopt(iface->dhcpv4_event.uloop.fd, SOL_SOCKET, SO_BINDTODEVICE, - iface->ifname, strlen(iface->ifname))) { + iface->ifname, strlen(iface->ifname)) < 0) { syslog(LOG_ERR, "setsockopt(SO_BINDTODEVICE): %m"); ret = -1; goto out; } - if (bind(iface->dhcpv4_event.uloop.fd, (struct sockaddr*)&bind_addr, sizeof(bind_addr))) { + if (bind(iface->dhcpv4_event.uloop.fd, (struct sockaddr*)&bind_addr, + sizeof(bind_addr)) < 0) { syslog(LOG_ERR, "bind(): %m"); ret = -1; goto out; -- 2.30.2