diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-11-17 10:18:09 -0500 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-11-18 11:19:16 -0500 |
commit | f4a99aeb0252068ee78bf2158fb01fef6f4599ca (patch) | |
tree | 31028c3e796a4b1701a10a06ffe37d823360d783 /scheduler/log.c | |
parent | f950947148bd1867c247a211af7404056b2b2e36 (diff) | |
download | cups-f4a99aeb0252068ee78bf2158fb01fef6f4599ca.tar.gz |
Address multiple minor issues reported by the LGTM security scanner:
- Lots of usage of localtime and gmtime (use _r/_s versions instead -
Issue #5685)
- Some unnecessary comparisons
- Suppress checks that are not useful (header guards, short global names, and
the integer overflow checks which don't reflect the actual range of values)
Diffstat (limited to 'scheduler/log.c')
-rw-r--r-- | scheduler/log.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/scheduler/log.c b/scheduler/log.c index cdb5437dc..2bd1952f7 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -301,7 +301,7 @@ cupsdGetDateTime(struct timeval *t, /* I - Time value or NULL for current */ cupsd_time_t format) /* I - Format to use */ { struct timeval curtime; /* Current time value */ - struct tm *date; /* Date/time value */ + struct tm date; /* Date/time value */ static struct timeval last_time = { 0, 0 }; /* Last time we formatted */ static char s[1024]; /* Date/time string */ @@ -351,23 +351,23 @@ cupsdGetDateTime(struct timeval *t, /* I - Time value or NULL for current */ * (*BSD and Darwin store the timezone offset in the tm structure) */ - date = localtime(&(t->tv_sec)); + localtime_r(&(t->tv_sec), &date); if (format == CUPSD_TIME_STANDARD) snprintf(s, sizeof(s), "[%02d/%s/%04d:%02d:%02d:%02d %+03ld%02ld]", - date->tm_mday, months[date->tm_mon], 1900 + date->tm_year, - date->tm_hour, date->tm_min, date->tm_sec, + date.tm_mday, months[date.tm_mon], 1900 + date.tm_year, + date.tm_hour, date.tm_min, date.tm_sec, #ifdef HAVE_TM_GMTOFF - date->tm_gmtoff / 3600, (date->tm_gmtoff / 60) % 60); + date.tm_gmtoff / 3600, (date.tm_gmtoff / 60) % 60); #else timezone / 3600, (timezone / 60) % 60); #endif /* HAVE_TM_GMTOFF */ else snprintf(s, sizeof(s), "[%02d/%s/%04d:%02d:%02d:%02d.%06d %+03ld%02ld]", - date->tm_mday, months[date->tm_mon], 1900 + date->tm_year, - date->tm_hour, date->tm_min, date->tm_sec, (int)t->tv_usec, + date.tm_mday, months[date.tm_mon], 1900 + date.tm_year, + date.tm_hour, date.tm_min, date.tm_sec, (int)t->tv_usec, #ifdef HAVE_TM_GMTOFF - date->tm_gmtoff / 3600, (date->tm_gmtoff / 60) % 60); + date.tm_gmtoff / 3600, (date.tm_gmtoff / 60) % 60); #else timezone / 3600, (timezone / 60) % 60); #endif /* HAVE_TM_GMTOFF */ |