diff options
author | Ori Bernstein <ori@eigenstate.org> | 2020-08-24 14:47:10 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2020-08-24 14:47:10 -0700 |
commit | b1a13414cd5c9cc8682a66885fb0acd8654c90de (patch) | |
tree | e0239adfa398686efeb137bc980ae61a30195932 /sys/src/libc | |
parent | 0505f8fb3a88e952709aaead1e13971b6e8514f3 (diff) |
tm2sec: clear new fields in tm
Old users of the time APIs would hand-craft
time structs without first zeroing all the
members. When this got into tmnorm(), we
would try to access the new members, and
things would go off the rails.
This makes tm2sec() clear the new fields
before passing them to the new APIs, so
that the hand-crafted structs remain
valid.
Diffstat (limited to 'sys/src/libc')
-rw-r--r-- | sys/src/libc/9sys/tm2sec.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/src/libc/9sys/tm2sec.c b/sys/src/libc/9sys/tm2sec.c index 8b3a9d967..1959e7980 100644 --- a/sys/src/libc/9sys/tm2sec.c +++ b/sys/src/libc/9sys/tm2sec.c @@ -7,5 +7,14 @@ tm2sec(Tm *tm) Tm tt; tt = *tm; + /* + * The zone offset should be calculated, + * but old code may not init tz member. + * nil it out so we don't access junk. + * while we're at it, old code probably + * leaves junk in nsec. + */ + tt.nsec = 0; + tt.tz = nil; return tmnorm(&tt); } |