File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Security/CWE/CWE-676/semmle/PotentiallyDangerousFunction Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- | test.c:28 :22:28 :27 | call to gmtime | Call to gmtime is potentially dangerous |
2- | test.c:39 :2:39 :5 | call to gets | gets does not guard against buffer overflow |
3- | test.c:40 :6:40 :9 | call to gets | gets does not guard against buffer overflow |
1+ | test.c:31 :22:31 :27 | call to gmtime | Call to gmtime is potentially dangerous |
2+ | test.c:42 :2:42 :5 | call to gets | gets does not guard against buffer overflow |
3+ | test.c:43 :6:43 :9 | call to gets | gets does not guard against buffer overflow |
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ struct tm {
2121
2222struct tm * gmtime (const time_t * timer );
2323time_t time (time_t * timer );
24+ struct tm * localtime (const time_t * timer );
25+ char * ctime (const time_t * timer );
26+ char * asctime (const struct tm * timeptr );
2427
2528// Code under test
2629
@@ -39,3 +42,10 @@ void testGets() {
3942 gets (buf1 ); // BAD: use of gets
4043 s = gets (buf2 ); // BAD: use of gets
4144}
45+
46+ void testTime ()
47+ {
48+ struct tm * now = localtime (time (NULL )); // BAD: localtime uses shared state [NOT DETECTED]
49+ char * time_string = ctime (time (NULL )); // BAD: localtime uses shared state [NOT DETECTED]
50+ char * time_string2 = asctime (now ); // BAD: localtime uses shared state [NOT DETECTED]
51+ }
You can’t perform that action at this time.
0 commit comments