PATCH: udhcpd "option domain" multiple values

Denis Vlasenko vda.linux at googlemail.com
Fri Feb 2 01:55:13 UTC 2007


On Friday 02 February 2007 02:23, Gabriel L. Somlo wrote:
> On Thu, Feb 01, 2007 at 11:08:20PM +0100, Denis Vlasenko wrote:
> > You can overflow existing->data[OPT_LEN].
> 
> Yes, by exactly 1 :)
> 
> >         /* add it to an existing option */
> 
> ...
> 
> >                 if (existing->data[OPT_LEN] + length <= 255) {
> >                         existing->data = xrealloc(existing->data,
> >                                         existing->data[OPT_LEN] + length + 3);
> >                         if ((option->flags & TYPE_MASK) == OPTION_STRING) {
> >                                 if (existing->data[OPT_LEN] + length >= 255)
> >                                         return;
> 
> You already know that's never going to be more than 255 (see the if
> statement at the beginning of the quote :) What you don't know is
> whether the extra space I want to add will make it 256 instead of 255.
> So, maybe do this:
> 
> >                               if (existing->data[OPT_LEN] + length + 1>= 255)
>                                                                      ^^^^^
> >                                         return;

No. My check is really

		if (existing->data[OPT_LEN] + length == 255)

that is, "is it exactly 255? that wont fit because of +1!"
but I use >= because of sheer paranoia. ;)

--
vda



More information about the busybox mailing list