[BusyBox] busybox-1.00-pre2 printf feature ?

Erik Andersen andersen at codepoet.org
Fri Aug 8 07:58:41 UTC 2003


On Thu Aug 07, 2003 at 03:31:48PM +0400, Vladimir N. Oleynik wrote:
> Manuel.
> 
> all strtol-based function from latest stable uclibc is broken.
> 
> #include <stdlib.h>
> 
> int main(void)
> {
>         const char *p = "1";
>         int i;
> 
>         i = atoi(p);
>         return printf("%s=%d\n", i, p);
> }
> 
> for Mar  3 2003 snapshot give "segmentation fault".

Your test app will also segfault with glibc too, since
you have the arguments to printf backwards...

Testing with glibc:

    $ gcc -Wall -O2 foo.c -o foo
    foo.c: In function `main':
    foo.c:10: warning: format argument is not a pointer (arg 2)
    foo.c:10: warning: int format, pointer arg (arg 3)
    $ ldd ./foo
	    libc.so.6 => /lib/libc.so.6 (0x40024000)
	    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    $ ./foo 
    Segmentation fault

If you fix your test app:

    -    return printf("%s=%d\n", i, p);
    +    return printf("%s=%d\n", p, i);

then it works perfectly with both glibc and uClibc.

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the busybox mailing list