If the IP header length does not match the size of the UDP packet received
via the raw socket, print both lengths in the warning message.
This commit is contained in:
parent
730e5ef310
commit
58b4ba768c
12
src/dhcp.c
12
src/dhcp.c
@ -252,13 +252,12 @@ static ssize_t get_raw_packet(struct client_state_t *cs,
|
|||||||
__func__, strerror(errno));
|
__func__, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
size_t iphdrlen = ntohs(packet.ip.tot_len);
|
||||||
if (inc != ntohs(packet.ip.tot_len)) {
|
if ((size_t)inc != iphdrlen) {
|
||||||
log_warning("%s: UDP length does not match header length fields.",
|
log_warning("%s: UDP length [%zd] does not match header length field [%zu].",
|
||||||
client_config.interface);
|
client_config.interface, inc, iphdrlen);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cs->using_dhcp_bpf && !get_raw_packet_validate_bpf(&packet))
|
if (!cs->using_dhcp_bpf && !get_raw_packet_validate_bpf(&packet))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
@ -272,8 +271,7 @@ static ssize_t get_raw_packet(struct client_state_t *cs,
|
|||||||
client_config.interface);
|
client_config.interface);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
size_t l = iphdrlen - sizeof packet.ip - sizeof packet.udp;
|
||||||
size_t l = ntohs(packet.ip.tot_len) - sizeof packet.ip - sizeof packet.udp;
|
|
||||||
memcpy(payload, &packet.data, l);
|
memcpy(payload, &packet.data, l);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user