strncmp("aa", "ab", -1)

Khem Raj raj.khem at gmail.com
Wed Sep 24 18:03:24 UTC 2008


On Wed, Sep 24, 2008 at 1:09 AM, Tobias Poschwatta <tp at fonz.de> wrote:
> Hi,
>
> while investigating wrong results from busybox's uniq applet, I found
> that strncmp returns unexpected results for n == -1.
>
> Here's the test program:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main(int argc, char **argv)
> {
>        printf("%d\n", strncmp("aa", "ab", -1));
>        exit(0);
> }
>
>
> On glibc/i386, it prints -1.
> On uclibc/arm/oabi/no-thumb, I get 0.
>
> My uclibc config is attached. I think it's using the assember version
> in libc/string/arm/strncmp.S. Unfortunately, I don't know enough ARM
> assembler to check that the function is handling n correctly as
> unsigned long (which is what size_t is supposed to be, right?).
>

which version of uclibc its failing on. Did you try it on trunk ?

Thx

-Khem



More information about the uClibc mailing list