summaryrefslogtreecommitdiff
path: root/time/tzfile.c
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-04-11 21:32:34 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-15 20:05:16 +0200
commit66f277a3a40f369ca8e583d410f5f7771da5aa61 (patch)
tree4b1b7e57f3fdd33bd8d75fa97a160ddecb5088db /time/tzfile.c
parent38a873073548a9a52136067df65cf47103e3342b (diff)
downloadglibc-aaribaud/tmp.tar.gz
Y2038: make __tz_convert compatible with 64-bit-timeaaribaud/tmp
This implies that its callers be 64-bit-time compatible too. It is done by creating 64-bit-time versions of these and turning their original 32-bit-time versions into wrappers (at a slight execution time cost). The callers affected are: * localtime * localtime_r * ctime * ctime_r * gmtime * gmtime_r Note that in time/tzfile.c we do not need to check for time_t overflows anymore as introduced by commit fc79706a323 since we now use internal_time_t.
Diffstat (limited to 'time/tzfile.c')
-rw-r--r--time/tzfile.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/time/tzfile.c b/time/tzfile.c
index d7e391c3a3..eddc0f825a 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -113,6 +113,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
size_t tzspec_len;
char *new = NULL;
+ _Static_assert (sizeof (time_t) == 8,
+ "time_t must be eight bytes");
+
_Static_assert (sizeof (__time64_t) == 8,
"__time64_t must be eight bytes");
@@ -635,16 +638,10 @@ __tzfile_compute (__time64_t timer, int use_localtime,
/* Convert to broken down structure. If this fails do not
use the string. */
- {
- time_t truncated = timer;
- if (__glibc_unlikely (truncated != timer
- || ! __offtime (&truncated, 0, tp)))
- goto use_last;
- }
-
- /* Use the rules from the TZ string to compute the change.
- timer fits into time_t due to the truncation check
- above. */
+ if (__glibc_unlikely (! __offtime (timer, 0, tp)))
+ goto use_last;
+
+ /* Use the rules from the TZ string to compute the change. */
__tz_compute (timer, tp, 1);
/* If tzspec comes from posixrules loaded by __tzfile_default,