arp.c: If the safe_read that fetches arp responses encounters a

return of -1 with errno == EAGAIN or EWOULDBLOCK, then report the
error, as it should never happen given that the function is called
only once after polling for ready-reads.

Further, the old code was buggy; it would subtract from the arpreply_offset
the return value of -1 in that case, which is just wrong.
This commit is contained in:
Nicholas J. Kain 2014-04-06 06:02:03 -04:00
parent 8b4c7f05b2
commit 7b0db5b8d3

View File

@ -712,15 +712,13 @@ void handle_arp_response(struct client_state_t *cs)
int r = 0;
if (arpreply_offset < sizeof arpreply) {
r = safe_read(cs->arpFd, (char *)&arpreply + arpreply_offset,
sizeof arpreply - arpreply_offset);
if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) {
sizeof arpreply - arpreply_offset);
if (r < 0) {
log_error("arp: ARP response read failed: %s", strerror(errno));
switch (arpState) {
case AS_COLLISION_CHECK: arp_failed(cs); break;
case AS_GW_CHECK: arp_gw_failed(cs); break;
default:
arp_reopen_fd(cs);
break;
case AS_COLLISION_CHECK: arp_failed(cs); break;
case AS_GW_CHECK: arp_gw_failed(cs); break;
default: arp_reopen_fd(cs); break;
}
} else
arpreply_offset += r;