strncat(dest,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA",sizeof(dest)-1);// no-warning - the code might assume that dest is empty
strncat(dest,src,sizeof(src));// expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest,src,sizeof(src)-1);// expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest,"AAAAAAAAAAAAAAAAAAAAAAAAAAA",sizeof(dest));// expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",sizeof(dest)-strlen(dest));// expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat((*s5)->f2[x],s2,sizeof(s2));// expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(s1+3,s2,sizeof(s2));// expected-warning {{size argument in 'strncat' call appears to be size of the source}}
strncat(s4.f1,s2,sizeof(s2));// expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
}
// Don't issue FIXIT for flexible arrays.
structS{
inty;
charx[];
};
voidflexible_arrays(structS*s){
charstr[]="hi";
strncat(s->x,str,sizeof(str));// expected-warning {{size argument in 'strncat' call appears to be size of the source}}
}
// Don't issue FIXIT for destinations of size 1.
voidsize_1(){
charz[1];
charstr[]="hi";
strncat(z,str,sizeof(z));// expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}}
}
// Support VLAs.
voidvlas(intsize){
charz[size];
charstr[]="hi";
strncat(z,str,sizeof(str));// expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}