Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a82832e

Browse files
committed
CPP: Add a test that uses 'gets'.
1 parent bbc8e78 commit a82832e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • cpp/ql/test/query-tests/Security/CWE/CWE-676/semmle/PotentiallyDangerousFunction

cpp/ql/test/query-tests/Security/CWE/CWE-676/semmle/PotentiallyDangerousFunction/test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@ int is_morning() {
2828
struct tm *now = gmtime(time(NULL)); // BAD: gmtime uses shared state
2929
return (now->tm_hour < 12);
3030
}
31+
32+
char *gets(char *s);
33+
34+
void testGets() {
35+
char buf1[1024];
36+
char buf2 = malloc(1024);
37+
char *s;
38+
39+
gets(buf1); // BAD: use of gets
40+
s = gets(buf2); // BAD: use of gets
41+
}

0 commit comments

Comments
 (0)