We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d957c15 + 00c552f commit 6c50092Copy full SHA for 6c50092
cpp/ql/src/Security/CWE/CWE-676/PotentiallyDangerousFunction.c
@@ -1,12 +1,14 @@
1
// BAD: using gmtime
2
int is_morning_bad() {
3
- struct tm *now = gmtime(time(NULL));
+ const time_t now_seconds = time(NULL);
4
+ struct tm *now = gmtime(&now_seconds);
5
return (now->tm_hour < 12);
6
}
7
8
// GOOD: using gmtime_r
9
int is_morning_good() {
10
11
struct tm now;
- gmtime_r(time(NULL), &now);
12
+ gmtime_r(&now_seconds, &now);
13
return (now.tm_hour < 12);
14
0 commit comments