@@ -2,23 +2,22 @@ void workFunction_0(char *s) {
22 char buf [80 ];
33 strncat (buf , s , sizeof (buf )- strlen (buf )- 1 ); // GOOD
44 strncat (buf , s , sizeof (buf )- strlen (buf )); // BAD
5- strncat (buf , "fix" , sizeof (buf )- strlen (buf )); // BAD but usually the size of the buffer is calculated manually.
5+ strncat (buf , "fix" , sizeof (buf )- strlen (buf )); // BAD [NOT DETECTED]
66}
77void workFunction_1 (char * s ) {
88#define MAX_SIZE 80
99 char buf [MAX_SIZE ];
1010 strncat (buf , s , MAX_SIZE - strlen (buf )- 1 ); // GOOD
1111 strncat (buf , s , MAX_SIZE - strlen (buf )); // BAD
12- strncat (buf , "fix" , MAX_SIZE - strlen (buf )); // BAD but usually the size of the buffer is calculated manually.
12+ strncat (buf , "fix" , MAX_SIZE - strlen (buf )); // BAD [NOT DETECTED]
1313}
1414void workFunction_2_0 (char * s ) {
1515 char * buf ;
1616 int len = 80 ;
1717 buf = (char * ) malloc (len );
1818 strncat (buf , s , len - strlen (buf )- 1 ); // GOOD
1919 strncat (buf , s , len - strlen (buf )); // BAD
20- strncat (buf , "fix" , len - strlen (buf )); // BAD but usually the size of the buffer is calculated manually.
21- }
20+ strncat (buf , "fix" , len - strlen (buf )); // BAD [NOT DETECTED]
2221void workFunction_2_1 (char * s ) {
2322 char * buf ;
2423 int len = 80 ;
0 commit comments