diff options
author | Martin Matuska <martin@matuska.de> | 2022-12-08 00:20:58 +0100 |
---|---|---|
committer | Martin Matuska <martin@matuska.de> | 2022-12-08 00:24:33 +0100 |
commit | 0d7cc9a041461ba03de90476db2c9bcb0a391112 (patch) | |
tree | 263422e4e18170e54eae9c45db2c9b1b9985f998 /libarchive/test/test_write_format_zip_compression_store.c | |
parent | 673d82c57ca7dd098dfd421250b0c3289825e837 (diff) | |
download | libarchive-0d7cc9a041461ba03de90476db2c9bcb0a391112.tar.gz |
tests: silence localtime() CodeQL warnings
Use localtime_r() or _localtime64_s() if available
Diffstat (limited to 'libarchive/test/test_write_format_zip_compression_store.c')
-rw-r--r-- | libarchive/test/test_write_format_zip_compression_store.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index c969a41d..ed090878 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -128,12 +128,31 @@ static void verify_uncompressed_contents(const char *buff, size_t used) /* Misc variables */ unsigned long crc; - struct tm *tm = localtime(&now); - + struct tm *tm; +#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) + struct tm tmbuf; +#endif +#if defined(HAVE__LOCALTIME64_S) + errno_t terr; + __time64_t tmptime; +#endif /* p is the pointer to walk over the central directory, * q walks over the local headers, the data and the data descriptors. */ const char *p, *q, *local_header, *extra_start; +#if defined(HAVE_LOCALTIME_R) + tm = localtime_r(&now, &tmbuf); +#elif defined(HAVE__LOCALTIME64_S) + tmptime = now; + terr = _localtime64_s(&tmbuf, &tmptime); + if (terr) + tm = NULL; + else + tm = &tmbuf; +#else + tm = localtime(&now); +#endif + /* Remember the end of the archive in memory. */ buffend = buff + used; |