summaryrefslogtreecommitdiff
path: root/lib/time_rz.c
Commit message (Collapse)AuthorAgeFilesLines
* Put LGPLv3+ notices in source files where appropriate.Bruno Haible2021-06-041-8/+8
| | | | | * lib/**.{h,c}: Use LGPLv3+ notice whenever the module description says so.
* nstrftime, time_rz: Avoid using an obsolete Autoconf macro.Bruno Haible2021-01-041-8/+8
| | | | | | | | | | | Reported by Mike Gran <spk121@yahoo.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00067.html>. * lib/time-internal.h: Test HAVE_STRUCT_TM_TM_ZONE, not HAVE_TM_ZONE. * lib/time_rz.c: Likewise. * lib/nstrftime.c: Set and test HAVE_STRUCT_TM_TM_ZONE, not HAVE_TM_ZONE. * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Update comments.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* time_rz: Use idx_t for nonnegative ptrdiff_t variables.Bruno Haible2020-12-061-1/+2
| | | | | | * lib/time_rz.c: Include idx.h. (save_abbr): Mark zone_size as nonnegative. * modules/time_rz (Depends-on): Add idx.
* time_rz: simplify CVE-2017-7476 fixPaul Eggert2020-11-111-13/+2
| | | | | | | | | * lib/time_rz.c: Do not include limits.h; I think it was included under the mistaken impression that limits.h defines SIZE_MAX. (SIZE_MAX): Remove. (save_abbr): Put string length into a ptrdiff_t variable, so that the size comparison works naturally. This fixes CVE-2017-7476 in a cleaner way.
* time_rz: remove unused functionsPaul Eggert2020-08-161-25/+0
| | | | * lib/time_rz.c (isdst_differ, equal_tm): Remove; no longer used.
* time_rz: fix issues with mktime_z failuresPaul Eggert2020-08-161-9/+17
| | | | | * lib/time_rz.c (mktime_z): Do not update *TM if revert_tz fails. Use a cheaper tm_yday test for failed mktime.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* time_rz: work around Mac OS X 10.6 infloopPaul Eggert2018-03-271-0/+15
| | | | | | | | | * doc/posix-functions/localtime.texi: * doc/posix-functions/localtime_r.texi: Mention the bug. * lib/time_rz.c (localtime_rz): Work around the bug. It’d be better to fix localtime and localtime_r instead, but that would be more work and is not needed to fix the Emacs problem. * m4/time_rz.m4 (gl_TIME_RZ): Detect the bug.
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* tzset: Work around TZ problem on native Windows.Bruno Haible2017-05-011-4/+0
| | | | | | | | | | | | * m4/tzset.m4 (gl_FUNC_TZSET): Require AC_CANONICAL_HOST. On native Windows, set REPLACE_TZSET to 1. * lib/tzset.c (tzset): On native Windows, fix TZ if necessary, and invoke '_tzset' instead of 'tzset'. * doc/posix-functions/tzset.texi: Mention the native Windows workaround. * modules/time_rz (Depends-on): Add tzset. * lib/time_rz.c (tzset): Remove fallback definition. * m4/time_rz.m4 (gl_TIME_RZ): Don't test for tzset.
* time_rz: fix heap buffer overflow vulnerabilityPádraig Brady2017-04-261-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This issue has been assigned CVE-2017-7476 and was detected with American Fuzzy Lop 2.41b run on the coreutils date(1) program with ASAN enabled. ERROR: AddressSanitizer: heap-buffer-overflow on address 0x... WRITE of size 8 at 0x60d00000cff8 thread T0 #1 0x443020 in extend_abbrs lib/time_rz.c:88 #2 0x443356 in save_abbr lib/time_rz.c:155 #3 0x44393f in localtime_rz lib/time_rz.c:290 #4 0x41e4fe in parse_datetime2 lib/parse-datetime.y:1798 A minimized reproducer is the following 120 byte TZ value, which goes beyond the value of ABBR_SIZE_MIN (119) on x86_64. Extend the aa...b portion to overwrite more of the heap. date -d $(printf 'TZ="aaa%020daaaaaab%089d"') localtime_rz and mktime_z were affected since commit 4bc76593. parse_datetime was affected since commit 4e6e16b3f. * lib/time_rz.c (save_abbr): Rearrange the calculation determining whether there is enough buffer space available. The rearrangement ensures we're only dealing with positive numbers, thus avoiding the problematic promotion of signed to unsigned causing an invalid comparison when zone_copy is more than ABBR_SIZE_MIN bytes beyond the start of the buffer. * tests/test-parse-datetime.c (main): Add a test case written by Paul Eggert, which overwrites enough of the heap so that standard glibc will fail with "free(): invalid pointer" without the patch applied. Reported and analyzed at https://bugzilla.redhat.com/1444774
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* flexmember: port better to GCC + valgrindPaul Eggert2016-09-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With a char[] flexible array member in a struct with nontrivial alignment, GCC-generated code can access past the end of the array, because GCC assumes there are padding bytes to get the struct aligned. So the common idiom of malloc (offsetof (struct s, m), n) does not properly allocate an n-byte trailing member, as malloc’s argument should be the next multiple of alignof (struct s). See GCC Bug#66661: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661 Although C11 apparently permits this GCC optimization (i.e., there was a bug in Gnulib not in GCC), possibly this is a defect in C11. See the thread containing: https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00317.html * lib/flexmember.h: New file. * lib/fnmatch.c, lib/fts.c, lib/glob.c, lib/idcache.c: * lib/localename.c, lib/time_rz.c: Include flexmember.h. * lib/fnmatch_loop.c (struct patternlist): * lib/localename.c (struct hash_node): Use FLEXIBLE_ARRAY_MEMBER. * lib/fnmatch_loop.c (EXT): * lib/fts.c (fts_alloc): * lib/glob.c (glob_in_dir): * lib/idcache.c (getuser, getuidbyname, getgroup, getgidbyname): * lib/localename.c (gl_lock_define_initialized): * lib/time_rz.c (tzalloc): Use FLEXSIZEOF instead of offsetof. * m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): Check that the size of the struct can be taken. * modules/flexmember (Files): Add lib/flexmember.h. * modules/fnmatch, modules/glob, modules/localename (Depends-on): Add flexmember.
* time_rz: port to clang -Wunused-const-variablePaul Eggert2016-03-151-4/+2
| | | | * lib/time_rz.c (TZ): Remove. All uses removed.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* time_rz: fix comment about tzallocPaul Eggert2015-10-201-2/+1
| | | | * lib/time_rz.c (tzalloc): Fix comment.
* time_rz: return NULL if localtime_r failsPaul Eggert2015-10-181-3/+2
| | | | | * lib/time_rz.c (localtime_rz): Return NULL if localtime_r fails, while still attempting to pacify bleeding-edge GCC.
* time_rz: avoid warning from bleeding-edge gcc's -WnonnullJim Meyering2015-10-181-2/+1
| | | | | | | | | | | | | | | | Compiling with gcc version 6.0.0 20151017 (experimental) (GCC), I would see this: lib/time_rz.c: In function 'localtime_rz': lib/time_rz.c:292:15: error: nonnull argument 'tm' compared to NULL \ [-Werror=nonnull] if (tm && !save_abbr (tz, tm)) ^ That was complaining about "tm" because it is a parameter that was declared with the __nonnull__ attribute. * lib/time_rz.c (localtime_rz): Don't bother setting "tm" to the result of localtime_r.
* time_rz: port to pedantic memcpyPaul Eggert2015-07-291-1/+3
| | | | | * lib/time_rz.c (tzalloc): Pacify pedantic memcpy implementations that reject memcpy (..., NULL, 0).
* time_rz: port better to MinGWPaul Eggert2015-07-271-74/+24
| | | | | | | | | | | | | | | | | | | | | | | | Don't change tzname, as this makes MinGW dump core (Bug#21020). Instead, store the tzname copy in the struct tm_zone object. Problem reported by Eli Zaretskii in: http://bugs.gnu.org/21020#48 * lib/strftime.c [!_LIBC]: * lib/time_rz.c: Include time-internal.h. * lib/strftime.c (strftime_case_) [!HAVE_TM_ZONE]: Infer the zone name from *TZ rather than from TZNAME, doable because *TZ now has a tzname_copy member. * lib/time-internal.h: New file, with contents taken from lib/time_rz.c. It's separate because strftime.c now accesses struct tm_zone members. (struct tm_zone) [HAVE_TZNAME && !HAVE_TM_ZONE]: New member tzname_copy. * lib/time_rz.c (struct tm_zone): Move to time-internal.h. (tzalloc) [HAVE_TZNAME && !HAVE_TM_ZONE]: Initialize tzname_copy member. (save_abbr) [HAVE_TZNAME && !HAVE_TM_ZONE]: Save abbreviation in tzname_copy member. (revert_tz) [HAVE_TZNAME]: Remove no-longer-needed tzname saving. (restore_tzname): Remove; no longer needed. All calls removed. * modules/time_rz (Files): Add lib/time-internal.h.
* time_rz: port to Solaris etc.Paul Eggert2015-07-251-3/+41
| | | | | | | | | | | | Works around a tzname problem on platforms like Solaris that have tzname but not tm_zone, by setting tzname at the appropriate time and restoring it later. * lib/time_rz.c (tzname_address, tzname_value) [HAVE_TZNAME]: New static vars. (save_abbr) [HAVE_TZNAME]: Set them. (revert_tz) [HAVE_TZNAME]: Clear or use them. (restore_tzname): New function. (localtime_rz, mktime_z): Use it.
* time_rz: make a constant 'const'Paul Eggert2015-07-251-1/+1
| | | | * lib/time_rz.c (local_tz): Now const.
* time_rz: fix off-by-one typoPaul Eggert2015-07-251-1/+1
| | | | * lib/time_rz.c (extend_abbrs): Fix off-by-one typo.
* time_rz: new modulePaul Eggert2015-07-231-0/+336
* MODULES.html.sh: Add time_rz. * lib/time_rz.c, m4/time_rz.m4, modules/time_rz: New files. * lib/time.in.h (timezone_t, tzalloc, tzfree, localtime_rz, mktime_z): New decls if _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@. * m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_DEFAULTS): New var HAVE_TIMEZONE_T (default 0). * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): New var GNULIB_TIME_RZ (default 0). * modules/time (time.h): Substitute the new vars.