From: Roy Marples Date: Tue, 25 Nov 2014 20:40:00 +0000 (+0000) Subject: Zero length UDP packets are not an error condition on the socket. X-Git-Tag: v6.6.3~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fddd88aed45b2b9573f14c46ebcdd01514417d23;p=thirdparty%2Fdhcpcd.git Zero length UDP packets are not an error condition on the socket. Thanks to Michał Kępień. --- diff --git a/arp.c b/arp.c index 86274a6d..3a1de858 100644 --- a/arp.c +++ b/arp.c @@ -124,7 +124,7 @@ arp_packet(void *arg) while (!(flags & RAW_EOF)) { bytes = if_readrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, sizeof(arp_buffer), &flags); - if (bytes == 0 || bytes == -1) { + if (bytes == -1) { syslog(LOG_ERR, "%s: arp if_readrawpacket: %m", ifp->name); dhcp_close(ifp); diff --git a/dhcp.c b/dhcp.c index 43e4046c..a98c5b95 100644 --- a/dhcp.c +++ b/dhcp.c @@ -2782,7 +2782,7 @@ dhcp_handlepacket(void *arg) while (!(flags & RAW_EOF)) { bytes = (size_t)if_readrawpacket(ifp, ETHERTYPE_IP, ifp->ctx->packet, udp_dhcp_len, &flags); - if (bytes == 0 || (ssize_t)bytes == -1) { + if ((ssize_t)bytes == -1) { syslog(LOG_ERR, "%s: dhcp if_readrawpacket: %m", ifp->name); dhcp_close(ifp); diff --git a/dhcp6.c b/dhcp6.c index 72d765e7..f4b77179 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -2551,7 +2551,7 @@ dhcp6_handledata(void *arg) ctx = dhcpcd_ctx->ipv6; ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); bytes = recvmsg(ctx->dhcp_fd, &ctx->rcvhdr, 0); - if (bytes == -1 || bytes == 0) { + if (bytes == -1) { syslog(LOG_ERR, "recvmsg: %m"); close(ctx->dhcp_fd); eloop_event_delete(dhcpcd_ctx->eloop, ctx->dhcp_fd, 0); diff --git a/ipv6nd.c b/ipv6nd.c index 574e69a2..56a7a4b3 100644 --- a/ipv6nd.c +++ b/ipv6nd.c @@ -1500,7 +1500,7 @@ ipv6nd_handledata(void *arg) ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); len = recvmsg(ctx->nd_fd, &ctx->rcvhdr, 0); - if (len == -1 || len == 0) { + if (len == -1) { syslog(LOG_ERR, "recvmsg: %m"); eloop_event_delete(dhcpcd_ctx->eloop, ctx->nd_fd, 0); close(ctx->nd_fd);