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 /tools | |
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 'tools')
-rw-r--r-- | tools/ippeveprinter.c | 8 | ||||
-rw-r--r-- | tools/ipptool.c | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/tools/ippeveprinter.c b/tools/ippeveprinter.c index 62489430b..2b921e235 100644 --- a/tools/ippeveprinter.c +++ b/tools/ippeveprinter.c @@ -7645,10 +7645,12 @@ time_string(time_t tv, /* I - Time value */ char *buffer, /* I - Buffer */ size_t bufsize) /* I - Size of buffer */ { - struct tm *curtime = localtime(&tv); - /* Local time */ + struct tm date; /* Local time and date */ + + localtime_r(&tv, &date); + + strftime(buffer, bufsize, "%X", &date); - strftime(buffer, bufsize, "%X", curtime); return (buffer); } diff --git a/tools/ipptool.c b/tools/ipptool.c index e54b78ad3..a3a694d5f 100644 --- a/tools/ipptool.c +++ b/tools/ipptool.c @@ -2162,16 +2162,16 @@ static char * /* O - ISO 8601 date/time string */ iso_date(const ipp_uchar_t *date) /* I - IPP (RFC 1903) date/time value */ { time_t utctime; /* UTC time since 1970 */ - struct tm *utcdate; /* UTC date/time */ + struct tm utcdate; /* UTC date/time */ static char buffer[255]; /* String buffer */ utctime = ippDateToTime(date); - utcdate = gmtime(&utctime); + gmtime_r(&utctime, &utcdate); snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ", - utcdate->tm_year + 1900, utcdate->tm_mon + 1, utcdate->tm_mday, - utcdate->tm_hour, utcdate->tm_min, utcdate->tm_sec); + utcdate.tm_year + 1900, utcdate.tm_mon + 1, utcdate.tm_mday, + utcdate.tm_hour, utcdate.tm_min, utcdate.tm_sec); return (buffer); } |