diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-14 18:09:02 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-14 18:09:02 +0000 |
commit | 5f2e5d97d66cc4dce88ed34fbd250376e1698b07 (patch) | |
tree | e9eb1c9c9e6fb0e49024e989c66d0d9c2b0f8a6f /sbin | |
parent | 3158bb5f28ce74f1fa731f592508a77ab7b383c0 (diff) |
When copying option.data, use option.len to specify the amount of
data to copy, rather than a static value that *may* be incorrect.
e.g. when option.data is NULL. Allows 'ignore subnet-mask;' to work.
Prompted by a different but similar problem found by jmc@.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index c295b08feb7..58d25da9a46 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.173 2012/11/14 15:47:41 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.174 2012/11/14 18:09:01 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -662,13 +662,14 @@ bind_lease(void) lease = apply_defaults(client->new); options = lease->options; - memcpy(&mask.s_addr, options[DHO_SUBNET_MASK].data, sizeof(in_addr_t)); + memcpy(&mask.s_addr, options[DHO_SUBNET_MASK].data, + options[DHO_SUBNET_MASK].len); add_address(ifi->name, ifi->rdomain, client->new->address, mask); if (options[DHO_ROUTERS].len) { memset(&gateway, 0, sizeof(gateway)); /* XXX Only use FIRST router address for now. */ memcpy(&gateway.s_addr, options[DHO_ROUTERS].data, - sizeof(in_addr_t)); + options[DHO_ROUTERS].len); add_default_route(ifi->rdomain, client->new->address, gateway); } if (options[DHO_DOMAIN_NAME].len) @@ -724,7 +725,7 @@ state_bound(void) if (client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) { memcpy(&client->destination.s_addr, client->active->options[DHO_DHCP_SERVER_IDENTIFIER].data, - sizeof(in_addr_t)); + client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len)); } else client->destination.s_addr = INADDR_BROADCAST; |