Skip to content

Commit aebf7bd

Browse files
authored
Update test.c
1 parent 5d5cd4f commit aebf7bd

File tree

1 file changed

+3
-4
lines changed
  • cpp/ql/test/experimental/query-tests/Security/CWE/CWE-788/semmle/tests

1 file changed

+3
-4
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-788/semmle/tests/test.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
77
void 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
}
1414
void 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]
2221
void workFunction_2_1(char *s) {
2322
char * buf;
2423
int len=80;

0 commit comments

Comments
 (0)