summaryrefslogtreecommitdiff
path: root/usr.sbin/dhcpd/options.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-10-19 15:43:34 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-10-19 15:43:34 +0000
commit45eebcbcf7d435b82ecc3ab8927332beb114f00a (patch)
treebd68ade3a6211fdde534a1b6fbe22c066a9f0c0e /usr.sbin/dhcpd/options.c
parent5a8fe992e3c04628531ef979727848d92899ba00 (diff)
Be a bit more paranoid and initialize all valid options buffers with
DHO_PAD (a.k.a. 0). Eliminate manual DHO_PAD'ing after DHO_END is put into the buffer. ok beck@
Diffstat (limited to 'usr.sbin/dhcpd/options.c')
-rw-r--r--usr.sbin/dhcpd/options.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/dhcpd/options.c b/usr.sbin/dhcpd/options.c
index 6ef4d8642a7..fc99d2a215e 100644
--- a/usr.sbin/dhcpd/options.c
+++ b/usr.sbin/dhcpd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.12 2007/10/19 15:34:55 krw Exp $ */
+/* $OpenBSD: options.c,v 1.13 2007/10/19 15:43:33 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -288,7 +288,13 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
(main_buffer_size + ((overload & 1) ? DHCP_FILE_LEN : 0)),
terminate);
- /* Put the cookie up front... */
+ /* Initialize the buffers to be used and put the cookie up front. */
+ memset(outpacket->options, DHO_PAD, sizeof(outpacket->options));
+ if (overload & 1)
+ memset(outpacket->file, DHO_PAD, DHCP_FILE_LEN);
+ if (overload & 2)
+ memset(outpacket->sname, DHO_PAD, DHCP_SNAME_LEN);
+
memcpy(outpacket->options, DHCP_OPTIONS_COOKIE, 4);
mainbufix = 4;
@@ -324,8 +330,6 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
mainbufix = option_size - bufix;
if (mainbufix < DHCP_FILE_LEN)
outpacket->file[mainbufix++] = (char)DHO_END;
- while (mainbufix < DHCP_FILE_LEN)
- outpacket->file[mainbufix++] = DHO_PAD;
} else {
memcpy(outpacket->file,
&buffer[bufix], DHCP_FILE_LEN);
@@ -339,8 +343,6 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
mainbufix = option_size - bufix;
if (mainbufix < DHCP_SNAME_LEN)
outpacket->sname[mainbufix++] = (char)DHO_END;
- while (mainbufix < DHCP_SNAME_LEN)
- outpacket->sname[mainbufix++] = DHO_PAD;
}
}
return (length);