[BusyBox] Bug in libbb/getopt_ulflags.c?

Glenn McGrath bug1 at iinet.net.au
Thu Feb 5 09:35:35 UTC 2004


On Wed, 04 Feb 2004 15:38:13 +0300
"Vladimir N. Oleynik" <dzo at simtreas.ru> wrote:

> No. New algorithm not require zeroed. But, I ready for look problem
> with real tests always ;-)

More details, demonstrate with debugging output.

uname args are "snrvmpa"

Testing each argument in order they are specified

$ ./busybox uname
bb_getopt_ulflags returns 0x0
Linux

$ ./busybox uname -s
bb_getopt_ulflags returns 0x40016331
Segmentation fault

$ ./busybox uname -n
bb_getopt_ulflags returns 0x2
localhost

$ ./busybox uname -r
bb_getopt_ulflags returns 0x80483f4
Linux localhost 2.6.2 #9 Thu Feb 5 18:29:25 EST 2004 i686 unknown

$ ./busybox uname -v
bb_getopt_ulflags returns 0x8
#9 Thu Feb 5 18:29:25 EST 2004

$ ./busybox uname -m
bb_getopt_ulflags returns 0xbffff234
Segmentation fault

$ ./busybox uname -p
bb_getopt_ulflags returns 0x20
unknown

$ ./busybox uname -a
bb_getopt_ulflags returns 0x804834d
Linux localhost 2.6.2 #9 Thu Feb 5 18:29:25 EST 2004 i686 unknown


As you can see from from the returned value, every second value is bad.

return value 0, 0x2, 0x8, 0x20 are good, 0x1, 0x4, 0x10 are bad.


This output is produced with the following diffs which just printing the
returned value from the "bad" version of bb_getopt_ulflags.

--- ./libbb/getopt_ulflags.c    22 Jan 2004 07:10:13 -0000      1.6
+++ ./libbb/getopt_ulflags.c    5 Feb 2004 09:12:12 -0000
@@ -88,6 +88,7 @@
   t_complementaly *on_off;
   va_list p;
  
+// memset(&complementaly, 0, sizeof(complementaly));
   va_start (p, applet_opts);
  
   /* skip GNU extension */

--- ./coreutils/uname.c 19 Mar 2003 09:11:34 -0000      1.19
+++ ./coreutils/uname.c 5 Feb 2004 09:12:12 -0000
@@ -72,10 +72,10 @@
        char *fake_sparc = getenv("FAKE_SPARC");
 #endif
        const unsigned short int *delta;
-       char toprint;
+       unsigned long toprint;
  
        toprint = bb_getopt_ulflags(argc, argv, options);
-
+       printf("bb_getopt_ulflags returns 0x%lx\n", toprint);
        if (argc != optind) {
                bb_show_usage();
        }



Glenn



More information about the busybox mailing list