[patch] cope with buggy dhcp servers

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sat Nov 24 15:24:22 UTC 2007


On Sat, 24 Nov 2007, walter harms wrote:

>    a few comments on you patch:
>
>    if (end + string[OPT_LEN] + 2 + 1 >= UDHCP_OPTIONS_BUFF_SIZE_MIN) {
>  		bb_error_msg("option 0x%02x did not fit into the packet",
>  				string[OPT_CODE]);
>    you know what packet so you can tell like:
>
> 	"broken option 0x%02x causes Option buffer overrun",string[OPT_CODE]);
>
>    or (so people have a change to adjust the buffer, perhaps mention the
>    RFC )

> 	"DHCPD option 0x%02x violates RFC3397, %d bytes to
>       large",string[OPT_CODE] ,end + string[OPT_LEN] + 2 +
>       1-UDHCP_OPTIONS_BUFF_SIZE_MIN);
>         (calc the suff in advance would be nice :)
>     i like this because it says *who* is to blame and *why* is it to
>     blame and *what* size to put into UDHCP_OPTIONS_SLACK_FOR_BUGGY_SERVERS

Right.  That may be a good idea.  Denys, what do you think?

>   btw: naming variables:
> 	UDHCP_OPTIONS_BUFF_SIZE_MIN translates for me into *minimum* buf size.
> 	(is there an BUF_SIZE_MAX ?)

MAX is indirectly set by the range in Config.in:

config UDHCP_OPTIONS_SLACK_FOR_BUGGY_SERVERS
	int "DHCP options slack buffer size"
	default 0
	range 0 896
		^^^
> 	any reason not to call it UDHCP_OPTIONS_BUFF_SIZE ?

Reason to call it ..._MIN is in rfc2131 (the "312 octets" here below):

"The 'options' field is now variable length. A DHCP client must be
prepared to receive DHCP messages with an 'options' field of at least
length 312 octets.  This requirement implies that a DHCP client must be
prepared to receive a message of up to 576 octets, the minimum IP datagram
size an IP host must be prepared to accept."

And continues like this:

"DHCP clients may negotiate the use of larger DHCP messages through the
'maximum DHCP message size' option.  The options field may be further
extended into the 'file' and 'sname' fields.

But AFAICS, udhcpc don't do "maximum DHCP message size".

"The client SHOULD include the 'maximum DHCP message size' option to let
the server know how large the server may make its DHCP messages.  The
parameters returned to a client may still exceed the space allocated to
options in a DHCP message.  In this case, two additional options flags
(which must appear in the 'options' field of the message) indicate that
the 'file' and 'sname' fields are to be used for options."

The words SHOULD and MUST are important.  udhcpc does the MUST and
some of the SHOULD stuff too.


Cheers,

-- 
Cristian



More information about the busybox mailing list