diff options
author | Ralph Boehme <slow@samba.org> | 2019-11-29 08:43:21 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-12-06 00:17:36 +0000 |
commit | f2af647e7dd9fce537ce1c82e965486eee79aa27 (patch) | |
tree | 5fca19f5b398ada3eabf9bb53ebed722307e0031 /lib/util/time.c | |
parent | 7a69f642d7b138255a73ef42ab6dd9a5e50e5309 (diff) | |
download | samba-f2af647e7dd9fce537ce1c82e965486eee79aa27.tar.gz |
lib: canonicalize pull_dos_date3()
Returns 0xFFFFFFFF as (time_t)-1. This avoids misenterpreting 0xFFFFFFFF as a
valid time_t value (0xFFFFFFFF = Sun 07 Feb 2106 06:28:15 AM GMT) on 64-bit
platforms where time_t is 64-bit.
Currently direct and indirect callers of pull_dos_date3() rely on the fact that
the resulting time_t is checked with null_time() which also checks for
0xFFFFFFFF as sentinel value amongst 0 and -1:
return t == 0 ||
t == (time_t)0xFFFFFFFF ||
t == (time_t)-1;
By returning -1 instead of 0xFFFFFFFF, callers can safely pass the result to
unix_to_nt_time() which *doesn't* check for 0xFFFFFFFF, only -1.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/util/time.c')
-rw-r--r-- | lib/util/time.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c index 46d188eb897..0875c9fbda9 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -326,6 +326,11 @@ _PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset) _PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset) { time_t t = (time_t)IVAL(date_ptr,0); + + if (t == (time_t)0xFFFFFFFF) { + t = (time_t)-1; + } + if (!null_time(t)) { t += zone_offset; } |