[BusyBox 0000980]: patch to avoid "broadcast +" syntax

Denis Vlasenko vda.linux at googlemail.com
Sun Nov 26 02:46:05 UTC 2006


On Saturday 25 November 2006 20:19, Roberto A. Foglietta wrote:
> Denis Vlasenko ha scritto:
> 
> > So far I was not able to extract this information from you.
> > I am trying to reproduce this supposedly buggy behavior but it works for me.
> > Should I mention that it took some effort to just extract testcase
> > from you?
> > 
> > +       while (!stop) {
> > +               if((p = *++argv)) {
> > +                       ;
> > +               } else
> > +               if(is_BROADCAST_able()) {
> > +                       p = "broadcast";
> > +                       stop = 1;
> > +               } else
> > +                       break;
> > 
> > Do you understand that busybox is not Obfuscated C contest?
> > 
> > +       while (!stop) {
> > +               p = *++argv;
> > +               if (!p) {
> > +                       if (!is_BROADCAST_able())
> > +                             break;
> > +                       p = "broadcast";
> > +                       stop = 1;
> > +               }
> 
>   My patch was not carrying obfuscated code but working one!
> :-)

I did not say that your code doesn't work. I said that it is
needlessly complex. Instead of three-way if() you can have just two.
See above.


>   Applaying just only the printfes you suggested I got this on my 
> mandriva 10.2 desktop running on my notebook (a Packard Bell Easynote 
> A5360):
> 
> [root at nbraf _install]# bin/busybox ifconfig eth0 172.16.128.23
> [root at nbraf _install]# bin/busybox ifconfig eth0
> eth0      Link encap:Ethernet  HWaddr 00:C0:9F:72:A8:91
>            inet addr:172.16.128.23  Bcast:172.16.255.255  Mask:255.255.0.0
> 
> 
> [root at nbraf _install]# bin/busybox ifconfig eth0 172.16.128.23 netmask 
> 255.255.255.0
> p = broadcast
> setting BROADCAST <------------------------------------ HERE!!!
> [root at nbraf _install]# bin/busybox ifconfig eth0
> eth0      Link encap:Ethernet  HWaddr 00:C0:9F:72:A8:91
>            inet addr:172.16.128.23  Bcast:172.16.128.255  Mask:255.255.255.0
> 
>   Try yourself in attachment my original obfuscated patch, the printf 
> patch and the config. Are you sure we are playing in the same team?
>   We are playing in the same team VDA, I am pretty sure about this!

Tried that. I see that with patch it sometimes does trigger
broadcast code. However, without that kernel seem to take care
of that anyway: with original bbox 1.1.3 with just printf("setting BROADCAST")
added, I do not get "setting BROADCAST" message, but broadcast is
set correctly. Modified bbox prints "setting BROADCAST", and broadcast
is set correctly too.


However:

        while (!stop) {
                if((p = *++argv)) {
                        ;
                } else
                if(is_BROADCAST_able()) {
printf("p = broadcast\n");
                        p = "broadcast";
                        stop = 1;


Here *argv is NULL, right?


                } else
                        break;

                mask = N_MASK;
                if (*p == '-') {        /* If the arg starts with '-'... */
                        ++p;            /*    advance past it and */
                        mask = M_MASK;  /*    set the appropriate mask. */
                }
                for (op = OptArray; op->name; op++) {   /* Find table entry. */
                        if (strcmp(p, op->name) == 0) { /* If name matches... */
                                if ((mask &= op->flags)) {      /* set the mask and go. */
                                        goto FOUND_ARG;

Here we will jump

                                }
                                /* If we get here, there was a valid arg with an */
                                /* invalid '-' prefix. */
                                ++goterr;
                                goto LOOP;
                        }
                }

                /* We fell through, so treat as possible hostname. */
                a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1;
                mask = op->arg_flags;
                goto HOSTNAME;

          FOUND_ARG:
                if (mask & ARG_MASK) {
                        mask = op->arg_flags;
                        a1op = Arg1Opt + (op - OptArray);
                        if (mask & A_NETMASK & did_flags) {
                                bb_show_usage();
                        }
                        if (*++argv == NULL) {
                                if(stop) {


Where does argv point now? After this ++argv above?
Past ifconfig argument list end, right? So this if() check
is buggy.
--
vda



More information about the busybox mailing list