returnstrlen(0);// expected-warning{{Null pointer argument in call to byte string function}}
}
size_tstrlen_fn(){
returnstrlen((char*)&strlen_fn);// expected-warning{{Argument to byte string function is the address of the function 'strlen_fn', which is not a null-terminated string}}
}
size_tstrlen_nonloc(){
label:
returnstrlen((char*)&&label);// expected-warning{{Argument to byte string function is the address of the label 'label', which is not a null-terminated string}}
returnstrnlen(0,3);// expected-warning{{Null pointer argument in call to byte string function}}
}
size_tstrnlen_fn(){
returnstrnlen((char*)&strlen_fn,3);// expected-warning{{Argument to byte string function is the address of the function 'strlen_fn', which is not a null-terminated string}}
}
size_tstrnlen_nonloc(){
label:
returnstrnlen((char*)&&label,3);// expected-warning{{Argument to byte string function is the address of the label 'label', which is not a null-terminated string}}
strcpy(NULL,x);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrcpy_null_src(char*x){
strcpy(x,NULL);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrcpy_fn(char*x){
strcpy(x,(char*)&strcpy_fn);// expected-warning{{Argument to byte string function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
}
voidstrcpy_effects(char*x,char*y){
chara=x[0];
if(strcpy(x,y)!=x)
(void)*(char*)0;// no-warning
if(strlen(x)!=strlen(y))
(void)*(char*)0;// no-warning
if(a!=x[0])
(void)*(char*)0;// expected-warning{{null}}
}
voidstrcpy_overflow(char*y){
charx[4];
if(strlen(y)==4)
strcpy(x,y);// expected-warning{{Byte string function overflows destination buffer}}
strncpy(NULL,x,1);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrncpy_null_src(char*x){
strncpy(x,NULL,1);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrncpy_fn(char*x){
strncpy(x,(char*)&strncpy_fn,1);// expected-warning{{Argument to byte string function is the address of the function 'strncpy_fn', which is not a null-terminated string}}
}
voidstrncpy_effects(char*x,char*y){
chara=x[0];
if(strncpy(x,y,strlen(y))!=x)
(void)*(char*)0;// no-warning
if(strlen(x)!=strlen(y))
(void)*(char*)0;// no-warning
if(a!=x[0])
(void)*(char*)0;// expected-warning{{null}}
}
voidstrncpy_overflow(char*y){
charx[4];
if(strlen(y)==4)
strncpy(x,y,strlen(y));// expected-warning{{Byte string function overflows destination buffer}}
strcat(NULL,x);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrcat_null_src(char*x){
strcat(x,NULL);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrcat_fn(char*x){
strcat(x,(char*)&strcat_fn);// expected-warning{{Argument to byte string function is the address of the function 'strcat_fn', which is not a null-terminated string}}
}
voidstrcat_effects(char*y){
charx[8]="123";
size_torig_len=strlen(x);
chara=x[0];
if(strlen(y)!=4)
return;
if(strcat(x,y)!=x)
(void)*(char*)0;// no-warning
if((int)strlen(x)!=(orig_len+strlen(y)))
(void)*(char*)0;// no-warning
if(a!=x[0])
(void)*(char*)0;// expected-warning{{null}}
}
voidstrcat_overflow_0(char*y){
charx[4]="12";
if(strlen(y)==4)
strcat(x,y);// expected-warning{{Byte string function overflows destination buffer}}
}
voidstrcat_overflow_1(char*y){
charx[4]="12";
if(strlen(y)==3)
strcat(x,y);// expected-warning{{Byte string function overflows destination buffer}}
}
voidstrcat_overflow_2(char*y){
charx[4]="12";
if(strlen(y)==2)
strcat(x,y);// expected-warning{{Byte string function overflows destination buffer}}
strncat(NULL,x,4);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrncat_null_src(char*x){
strncat(x,NULL,4);// expected-warning{{Null pointer argument in call to byte string function}}
}
voidstrncat_fn(char*x){
strncat(x,(char*)&strncat_fn,4);// expected-warning{{Argument to byte string function is the address of the function 'strncat_fn', which is not a null-terminated string}}
}
voidstrncat_effects(char*y){
charx[8]="123";
size_torig_len=strlen(x);
chara=x[0];
if(strlen(y)!=4)
return;
if(strncat(x,y,strlen(y))!=x)
(void)*(char*)0;// no-warning
if(strlen(x)!=orig_len+strlen(y))
(void)*(char*)0;// no-warning
if(a!=x[0])
(void)*(char*)0;// expected-warning{{null}}
}
voidstrncat_overflow_0(char*y){
charx[4]="12";
if(strlen(y)==4)
strncat(x,y,strlen(y));// expected-warning{{Byte string function overflows destination buffer}}
}
voidstrncat_overflow_1(char*y){
charx[4]="12";
if(strlen(y)==3)
strncat(x,y,strlen(y));// expected-warning{{Byte string function overflows destination buffer}}
}
voidstrncat_overflow_2(char*y){
charx[4]="12";
if(strlen(y)==2)
strncat(x,y,strlen(y));// expected-warning{{Byte string function overflows destination buffer}}
}
voidstrncat_overflow_3(char*y){
charx[4]="12";
if(strlen(y)==4)
strncat(x,y,2);// expected-warning{{Byte string function overflows destination buffer}}