broken strndup on AIX 5.1

Doug VanLeuven roamdad at sonic.net
Mon Aug 23 20:34:47 GMT 2004


Thanks.  No I hadn't.  It's been open since Feb. I agree with you.  Why 
even use somrthing provably suspect?  It's not a performance issue.  
Your last post fails for me too on both AIX 5.1 & 5.2 in my build 
environment.  That's a nice piece of work.  I can't seem to post an 
additional comment to your bug in the bug thread, so I'll post it here.

I compile in the Linux affinity environment using gcc.
gcc-2.9.aix51.020209-4

I can document the behavior of AIX 4.3.3 strnlen as noted at gnu.org 
under autoconf documentation in section "5.5.1 Portability of C 
Functions" still exists on AIX 5.1.0.50 and AIX 5.2.0.30

#include <stdio.h>
#include <string.h>

main (int argc, char *argv[]) {
        int j,len;
        char namebuf[13] = "foobar";
        int jmax = strlen(namebuf)+1;

        for(j=0; j <jmax; j++) {
          len = strnlen(namebuf,j);
          printf("strlen(\"%s\",%d) = %d\n",namebuf,j,len);
        }
}

yeilds exactly the same results noted at gnu.org for AIX 4.3.3 on both 
AIX 5.1 and 5.2:

strlen(strndup("foobar",0)) = 0
strlen(strndup("foobar",1)) = 3
strlen(strndup("foobar",2)) = 2
strlen(strndup("foobar",3)) = 1
strlen(strndup("foobar",4)) = 0
strlen(strndup("foobar",5)) = 6
strlen(strndup("foobar",6)) = 6

Heinrich Mislik wrote:

>On 21 Aug 2004, at 17:31, Doug VanLeuven wrote:
>
>  
>
>>Hi,
>>AIX 5.1.0.50
>>samba 3_0 svn 1824
>>strndup in libc.a
>>
>>I could pass all the smbtorture tests except MANGLE.
>>This patch on an AIX illustrates the problem if smb.conf uses hash2 
>>method and allows MANGLE to succeed.
>>Neither are the build_farm AIX systems passing this test.
>>    
>>
>
>Did yous see
>
>https://bugzilla.samba.org/show_bug.cgi?id=1097
>
>Heinrich Mislik
>
>  
>


More information about the samba-technical mailing list