broken strndup on AIX 5.1
Doug VanLeuven
roamdad at sonic.net
Mon Aug 23 22:36:25 GMT 2004
Sorry about the error in cut & paste. I disagree strndup is OK. It
passes simple tests, but not complicated ones in conjunction with malloc.
Refer bug 1097
https://bugzilla.samba.org/show_bug.cgi?id=1097
and the recent contribution by Heinrich.Mislik to prove this.
I can test 4.3.3
Using your code
rs1scwa /root/src # uname -a
AIX rs6 3 4 000216FF4C00 unknown
rs1scwa /root/src # more strnlen.c
#include <stdio.h>
#include <string.h>
int main(void)
{
char *test = "1234567890";
int i;
for (i=0;i<9;i++) {
printf("%d\n", strnlen(test,i));
}
return 0;
}
rs1scwa /root/src # gcc strnlen.c -o strnlen
rs1scwa /root/src # ./strnlen
0
3
2
1
0
7
6
5
4
Simo Sorce wrote:
>On Mon, 2004-08-23 at 23:20, William Jojo wrote:
>
>
>>If I can help here. I do not have the gcc used, but I ran these test
>>programs using the IBM compiler on 5.2 and the listed filesets described
>>below. It appears that strndup is fine, but strnlen returns questionable
>>results.
>>
>>
>
>Yeah I just reproduced the same result on a 5.1 AIX box.
>
>strndup works fine, but strnlen give this result:
>
>strnlen.c
>-----------------------------------------------
>#include <stdio.h>
>#include <string.h>
>
>int main(void)
>{
> char *test = "1234567890";
> int i;
> for (i=0;i<9;i++) {
> printf("%d\n", strnlen(test,i));
> }
> return 0;
>}
>-----------------------------------------------
>./strnlen
>0
>3
>2
>1
>0
>7
>6
>5
>4
>
>Do anyone here have access to an AIX 4.3.3 box and check strndup is ok
>and strnlen broken here too?
>
>Simo.
>
>
>
More information about the samba-technical
mailing list