Allow receive of short dhcp packets over raw listen sockets.
This commit is contained in:
parent
08301a7053
commit
8b97107b8d
@ -227,23 +227,12 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
|
||||
|
||||
memset(&packet, 0, packet_size);
|
||||
int len = safe_read(fd, (char *)&packet, packet_size);
|
||||
if (len == -1) {
|
||||
if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
log_line("get_raw_packet: read error %s", strerror(errno));
|
||||
usleep(500000); /* possible down interface, looping condition */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len < header_size) {
|
||||
log_line("Message too short to contain IP + UDP headers, ignoring");
|
||||
sleep(1);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (len < ntohs(packet.ip.tot_len)) {
|
||||
log_line("Truncated packet");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* ignore any extra garbage bytes */
|
||||
len = ntohs(packet.ip.tot_len);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user