get_raw_packet(): Perform the UDP checksum after the packet length
checks. This change makes it easier to verify that there can be no reads beyond a buffer end by udp_checksum().
This commit is contained in:
parent
c8dcf5a06b
commit
6548b5ce54
10
src/dhcp.c
10
src/dhcp.c
@ -198,11 +198,6 @@ static ssize_t get_raw_packet(struct client_state_t *cs,
|
||||
client_config.interface);
|
||||
return -2;
|
||||
}
|
||||
if (packet.udp.check && !udp_checksum(&packet)) {
|
||||
log_error("%s: Packet with bad UDP checksum received. Ignoring.",
|
||||
client_config.interface);
|
||||
return -2;
|
||||
}
|
||||
if (iphdrlen <= sizeof packet.ip + sizeof packet.udp) {
|
||||
log_error("%s: Packet received that is too small (%zu bytes).",
|
||||
iphdrlen);
|
||||
@ -214,6 +209,11 @@ static ssize_t get_raw_packet(struct client_state_t *cs,
|
||||
l);
|
||||
return -2;
|
||||
}
|
||||
if (packet.udp.check && !udp_checksum(&packet)) {
|
||||
log_error("%s: Packet with bad UDP checksum received. Ignoring.",
|
||||
client_config.interface);
|
||||
return -2;
|
||||
}
|
||||
memcpy(payload, &packet.data, l);
|
||||
return l;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user