bug in dmesg parameter parsing (busybox 1.2.0)

Natanael Copa natanael.copa at gmail.com
Thu Jul 6 08:00:14 PDT 2006


On Thu, 2006-07-06 at 16:38 +0200, Bernhard Fischer wrote:
> On Thu, Jul 06, 2006 at 03:59:12PM +0200, Natanael Copa wrote:
> >Hi,
> >
> >I'm upgrading my 1.1.3 busybox to 1.2.0.
> >
> >I got bitten by this one:
> >
> >~ $ dmesg -c
> >dmesg: option requires an argument -- c
> >BusyBox v1.2.0 (2006.07.06-06:53+0000) multi-call binary
> >
> >Usage: dmesg [-c] [-n LEVEL] [-s SIZE]
> >
> >Prints or controls the kernel ring buffer
> >
> >Options:
> >        -c              Clears the ring buffer's contents after printing
> >        -n LEVEL        Sets console logging level
> >        -s SIZE         Use a buffer of size SIZE
> >
> >~ $ dmesg -n 1
> 
> This one just segfaulted on me.

Because the "c:s:n:" should be "cs:n:"?

--- util-linux/dmesg.c  (revision 15655)
+++ util-linux/dmesg.c  (working copy)
@@ -15,7 +15,7 @@
 int dmesg_main(int argc, char *argv[])
 {
        char *size, *level;
-       int flags = bb_getopt_ulflags(argc, argv, "c:s:n:", &size, &level);
+       int flags = bb_getopt_ulflags(argc, argv, "cs:n:", &size, &level);

        if (flags & 4) {
                if(klogctl(8, NULL, bb_xgetlarg(size, 10, 0, 10)))


But it still don't work. Seems like a bug in bb_getopt_ulflags?

> 
> I rewrote it, this version Works For Me (tm):
> http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_scratch/util-linux/dmesg.c

Thanks!

Would be nice to have this fixed in 1.2.1.




More information about the busybox mailing list