diff options
author | 2007-10-19 15:43:33 +0000 | |
---|---|---|
committer | 2007-10-19 15:43:33 +0000 | |
commit | 99a6dd6ff08b6c2c47aff86553230e797f74ab85 (patch) | |
tree | 43d35c98b3c3474c34bc2fc9e20bf388462dc84d | |
parent | Fix obvious typos and write DHO_PAD and DHO_END into correct options overflow (diff) | |
download | wireguard-openbsd-99a6dd6ff08b6c2c47aff86553230e797f74ab85.tar.xz wireguard-openbsd-99a6dd6ff08b6c2c47aff86553230e797f74ab85.zip |
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@
-rw-r--r-- | usr.sbin/dhcpd/options.c | 14 |
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); |