diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-07-09 08:58:00 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-07-09 08:58:55 +0200 |
commit | 345bba0889ae9deeac4ca805ebc3f0661b4b3988 (patch) | |
tree | 0f89f84b5a25deb44e5895801fdbe20bdeb91f05 /src/dhcpv4.c | |
parent | c0f63905c74b3b0b168a9cf7903ebaec6564c24c (diff) |
dhcpv4: improve error checking in handle_dhcpv4()
Check ioctl return value as reported by Coverity in CID1437659
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index dc10ba3..3386abb 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -928,19 +928,21 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, dest.sin_addr.s_addr = INADDR_BROADCAST; dest.sin_port = htons(DHCPV4_CLIENT_PORT); } else { + struct arpreq arp = {.arp_flags = ATF_COM}; + /* * send reply to the newly (in this proccess) allocated IP */ dest.sin_addr = reply.yiaddr; dest.sin_port = htons(DHCPV4_CLIENT_PORT); - struct arpreq arp = {.arp_flags = ATF_COM}; memcpy(arp.arp_ha.sa_data, req->chaddr, 6); memcpy(&arp.arp_pa, &dest, sizeof(arp.arp_pa)); memcpy(arp.arp_dev, iface->ifname, sizeof(arp.arp_dev)); - ioctl(sock, SIOCSARP, &arp); - } + if (ioctl(sock, SIOCSARP, &arp) < 0) + syslog(LOG_ERR, "ioctl(SIOCSARP): %m"); + } if (sendto(sock, &reply, sizeof(reply), MSG_DONTWAIT, (struct sockaddr*)&dest, sizeof(dest)) < 0) |