summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-11-24 18:06:15 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-11-24 18:06:15 +0000
commitfcbc6cf70863a4f7958222f71957bceeaa9837db (patch)
tree888765c58622e4315aadf18e0fe3348dc7ea5f40 /sbin
parent461be7c56c861c9833802d2830a324e5f06c21a5 (diff)
Don't segfault if no subnet-mask is provided, or is marked 'ignore'
in dhclient.conf. Always zero out stack masks rather than using stack garbage when no subnet-mask is provided.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c3
-rw-r--r--sbin/dhclient/dispatch.c5
2 files changed, 5 insertions, 3 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 038b74dfed6..b1820157647 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.179 2012/11/23 15:25:47 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.180 2012/11/24 18:06:14 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -666,6 +666,7 @@ bind_lease(void)
lease = apply_defaults(client->new);
options = lease->options;
+ memset(&mask, 0, sizeof(mask));
memcpy(&mask.s_addr, options[DHO_SUBNET_MASK].data,
options[DHO_SUBNET_MASK].len);
add_address(ifi->name, ifi->rdomain, client->new->address, mask);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index cd73f79d7d1..81e73313717 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.66 2012/11/23 15:25:47 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.67 2012/11/24 18:06:14 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -358,8 +358,9 @@ subnet_exists(struct client_lease *l)
struct in_addr mymask, myaddr, mynet, hismask, hisaddr, hisnet;
int myrdomain, hisrdomain;
+ memset(&mymask, 0, sizeof(mymask));
memcpy(&mymask.s_addr, l->options[DHO_SUBNET_MASK].data,
- sizeof(in_addr_t));
+ l->options[DHO_SUBNET_MASK].len);
myaddr.s_addr = l->address.s_addr;
mynet.s_addr = mymask.s_addr & myaddr.s_addr;