diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-07 15:40:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-07 15:40:14 +0000 |
commit | 538928de389c7c17af8cb6d465004e6e014899aa (patch) | |
tree | 3c8e6bfa4d86fce997380c01ecb6863e6abd3040 /sbin | |
parent | b896d1fc8a7706642e35f3bc2da1e0a160e0b8bb (diff) |
Always memcpy() into/out of option data rather than hoping the char *
will be always be aligned. Don't pass around pointers into option
data - use variable that has the memcpy()'d data.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/kroute.c | 16 |
3 files changed, 10 insertions, 16 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 5aa7e408e04..e89901d7424 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.168 2012/11/07 15:20:28 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.169 2012/11/07 15:40:13 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -658,7 +658,7 @@ bind_lease(void) struct iaddr gateway; struct option_data *options; struct client_lease *lease; - in_addr_t *mask = NULL; + in_addr_t mask; char *domainname, *nameservers; delete_old_addresses(ifi->name, ifi->rdomain); @@ -667,7 +667,7 @@ bind_lease(void) lease = apply_defaults(client->new); options = lease->options; - mask = (in_addr_t *)options[DHO_SUBNET_MASK].data; + memcpy(&mask, options[DHO_SUBNET_MASK].data, sizeof(mask)); add_new_address(ifi->name, ifi->rdomain, client->new->address, mask); if (options[DHO_ROUTERS].len) { memset(&gateway, 0, sizeof(gateway)); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index c67e0f0a3c5..ae491aea369 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.88 2012/11/06 00:05:11 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.89 2012/11/07 15:40:13 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -337,7 +337,7 @@ void delete_old_addresses(char *, int); void delete_old_address(char *, int, struct iaddr); void priv_delete_old_address(char *, int, struct iaddr); -void add_new_address(char *, int, struct iaddr, in_addr_t *); +void add_new_address(char *, int, struct iaddr, in_addr_t); void priv_add_new_address(char *, int, struct iaddr, in_addr_t); void flush_routes_and_arp_cache(int); diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 32916aac5d7..81b483a407d 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.11 2012/11/07 15:20:28 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.12 2012/11/07 15:40:13 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -496,9 +496,8 @@ priv_delete_old_address(char *ifname, int rdomain, struct iaddr addr) * route -q <rdomain> add <addr> 127.0.0.1 */ void -add_new_address(char *ifname, int rdomain, struct iaddr addr, in_addr_t *mask) +add_new_address(char *ifname, int rdomain, struct iaddr addr, in_addr_t mask) { - in_addr_t nomask; struct buf *buf; size_t len; struct imsg_hdr hdr; @@ -510,7 +509,7 @@ add_new_address(char *ifname, int rdomain, struct iaddr addr, in_addr_t *mask) sizeof(len) + strlen(ifname) + sizeof(len) + sizeof(rdomain) + sizeof(len) + sizeof(addr) + - sizeof(len) + sizeof(*mask); + sizeof(len) + sizeof(mask); buf = buf_open(hdr.len); buf_add(buf, &hdr, sizeof(hdr)); @@ -527,14 +526,9 @@ add_new_address(char *ifname, int rdomain, struct iaddr addr, in_addr_t *mask) buf_add(buf, &len, sizeof(len)); buf_add(buf, &addr, len); - len = sizeof(*mask); + len = sizeof(mask); buf_add(buf, &len, sizeof(len)); - if (mask) - buf_add(buf, mask, len); - else { - memset(&nomask, 0, sizeof(nomask)); - buf_add(buf, &nomask, len); - } + buf_add(buf, &mask, len); buf_close(privfd, buf); } |