diff options
author | Tom Gundersen <teg@jklm.no> | 2014-04-06 14:05:32 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-04-06 19:36:05 +0200 |
commit | 3b7ca119fdc501e21f017695dc9b6f82fdbd1d93 (patch) | |
tree | efefc912fa1925f1197dd0e5b56a14ad2282de38 /src/libsystemd-network/dhcp-option.c | |
parent | 19aa72f74e41045510b4af3f1415b419d42ff20b (diff) |
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.
Diffstat (limited to 'src/libsystemd-network/dhcp-option.c')
-rw-r--r-- | src/libsystemd-network/dhcp-option.c | 12 |
1 files changed, 4 insertions, 8 deletions
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; |