From 3b7ca119fdc501e21f017695dc9b6f82fdbd1d93 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 6 Apr 2014 14:05:32 +0200 Subject: sd-dhcp-client: move magic cookie into DHCPMessage struct Also move the checking of it to the main message handler, rather than the options parser. Fix a bug, so we now drop the packet if any of the magic bytes don't match. Before we used to only drop the packet if they were all wrong. --- src/libsystemd-network/dhcp-option.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/libsystemd-network/dhcp-option.c') diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c index 4d45b3b3a4..1b92e8616b 100644 --- a/src/libsystemd-network/dhcp-option.c +++ b/src/libsystemd-network/dhcp-option.c @@ -149,17 +149,13 @@ int dhcp_option_parse(DHCPMessage *message, size_t len, if (!message) return -EINVAL; - if (len < sizeof(DHCPMessage) + 4) + if (len < sizeof(DHCPMessage)) return -EINVAL; - len -= sizeof(DHCPMessage) + 4; + len -= sizeof(DHCPMessage); - if (opt[0] != 0x63 && opt[1] != 0x82 && opt[2] != 0x53 && - opt[3] != 0x63) - return -EINVAL; - - res = parse_options(&opt[4], len, &overload, &message_type, - cb, user_data); + res = parse_options(opt, len, &overload, &message_type, + cb, user_data); if (res < 0) return res; -- cgit v1.2.3-54-g00ecf