diff options
author | Tom Gundersen <teg@jklm.no> | 2014-02-23 19:21:50 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-02-23 22:59:43 +0100 |
commit | 8fa2eeace7beecedb01c82811e28949cacec1236 (patch) | |
tree | 88349a086ecc7ebb425de5514d64d6f901f0e3df /src/libsystemd-dhcp | |
parent | 5266a81ea2b5d355916695c1ecc8c4570a54727b (diff) |
sd-dhcp: don't reject packets with the 'wrong' source port
The RFC does not specify that the packets from the DHCP server must come from
the DHCP server port, only that that's where they should be sent.
This fixes a problem when running networkd in VirtualBox.
Thanks to Sébastien Luttringer for reporting the bug and very patiently testing
various fixes.
Diffstat (limited to 'src/libsystemd-dhcp')
-rw-r--r-- | src/libsystemd-dhcp/dhcp-packet.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd-dhcp/dhcp-packet.c b/src/libsystemd-dhcp/dhcp-packet.c index 8f9ec43c43..13881ea0dd 100644 --- a/src/libsystemd-dhcp/dhcp-packet.c +++ b/src/libsystemd-dhcp/dhcp-packet.c @@ -164,7 +164,7 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len) { return -EINVAL; } - if (hdrlen + be16toh(packet->udp.len) > len) { + if (len < hdrlen + be16toh(packet->udp.len)) { log_dhcp_client(client, "ignoring packet: packet (%zu bytes) " "smaller than expected (%zu) by UDP header", len, hdrlen + be16toh(packet->udp.len)); @@ -182,10 +182,10 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len) { } } - if (be16toh(packet->udp.source) != DHCP_PORT_SERVER || - be16toh(packet->udp.dest) != DHCP_PORT_CLIENT) { - log_dhcp_client(client, "ignoring packet: wrong ports (source: %u, destination: %u)", - be16toh(packet->udp.source), be16toh(packet->udp.dest)); + if (be16toh(packet->udp.dest) != DHCP_PORT_CLIENT) { + log_dhcp_client(client, "ignoring packet: to port %u, which " + "is not the DHCP client port (%u)", + be16toh(packet->udp.dest), DHCP_PORT_CLIENT); return -EINVAL; } |