[BusyBox] Bug on route.c

Manuel Novoa III mjn3 at codepoet.org
Fri Mar 19 23:33:01 UTC 2004


On Fri, Mar 19, 2004 at 11:58:53PM +0100, Pigi wrote:
> Hi all.
> I'm a familiar user, and I've noticed a bug in route.c in 1.00-pre8.
> If I issue the command
> route add default gw 192.168.0.1 usbf ( without the "dev" keyword )i get
> an error, while issuing the command route add default gw 192.168.0.1 dec
> usbf works.
> Same behavior with route add default usbf and route add default dev usbf

Sorry about that.  Got a bit to aggressive with size optimization and
didn't pay attention when doing a global replace.

> The fix seems easy. Here the patch:
> diff -u -b -B -w -p -r1.25 route.c
> --- a/route.c   15 Mar 2004 08:28:49 -0000      1.25
> +++ b/route.c   19 Mar 2004 22:30:27 -0000
> @@ -205,7 +205,12 @@ static void INET_setroute(int action, ch
> 
>         while (*args) {
>                 int k = kw_lookup(tbl_ipvx, &args);
> -               const char *args_m1 = args[-1];
> +               const char *args_m1 = NULL;
> +                if (k)
> +                 args_m1 = args[-1];
> +                else
> +                 args_m1 = *args;
> +
> 
>                 if (k & KW_IPVx_FLAG_ONLY) {
>                         rt.rt_flags |= flags_ipvx[k & 3];
> 
> 
> Can it be right ? ( at least it works for me )

No... the bug was in both ipv4 and ipv6 processing.  Also, it is better
to simply access args[-1] directly in the problem case (which is where
the global replace comes in).  Your approach adds unnecessary code.

Thanks for reporting the problem.

Manuel



More information about the busybox mailing list