diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-11-14 02:00:09 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-11-14 02:00:09 +0000 |
commit | f9363451dd38546284b55eac0afc96e5888b76cc (patch) | |
tree | e15550a6b19455304956d8f46ef214f202e8f82e | |
parent | 59177dbc17b56f435da37e57a085eba41f3f1d2f (diff) |
Sigh. Some clients can't handle three DHO_PAD options holding space
for an unused overload option. Noticed by mk@ when netbooting his
G4 mac mini.
So compact the options by shifting them over the unused option and
filling the end by DHO_PAD.
Tested by mk@.
-rw-r--r-- | usr.sbin/dhcpd/options.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/usr.sbin/dhcpd/options.c b/usr.sbin/dhcpd/options.c index bdd2215ae26..10dc064d996 100644 --- a/usr.sbin/dhcpd/options.c +++ b/usr.sbin/dhcpd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.23 2008/11/08 01:42:24 krw Exp $ */ +/* $OpenBSD: options.c,v 1.24 2008/11/14 02:00:08 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -460,16 +460,27 @@ zapfrags: buffer[bufix++] = DHO_END; /* Fill in overload option value based on space used for options. */ - overflow = bufix - main_buffer_size; - if (overload && overflow > 0) { - buffer[4] = DHO_DHCP_OPTION_OVERLOAD; - buffer[5] = 1; - if (overload & 1) { - buffer[6] |= 1; - overflow -= DHCP_FILE_LEN; + if (overload) { + overflow = bufix - main_buffer_size; + if (overflow > 0) { + buffer[4] = DHO_DHCP_OPTION_OVERLOAD; + buffer[5] = 1; + if (overload & 1) { + buffer[6] |= 1; + overflow -= DHCP_FILE_LEN; + } + if ((overload & 2) && overflow > 0) + buffer[6] |= 2; + } else { + /* + * Compact buffer to eliminate the unused + * DHO_DHCP_OPTION_OVERLOAD option. Some clients + * choke on DHO_PAD options there. + */ + memmove(&buffer[4], &buffer[7], buflen - 7); + bufix -= 3; + memset(&buffer[bufix], DHO_PAD, 3); } - if ((overload & 2) && overflow > 0) - buffer[6] |= 2; } return (bufix); |