|
|
Message-ID: <20261125180659.GS5716@brightrain.aerifal.cx>
Date: Wed, 25 Nov 2026 13:06:59 -0500
From: Rich Felker <dalias@...c.org>
To: 吴尚哲 <wushangzhe26@....pku.edu.cn>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: Bug in TZ rule handling: out-of-bounds read for an
invalid month
On Thu, Nov 26, 2026 at 01:43:24AM +0800, 吴尚哲 wrote:
> Hello,
> We found a bug in musl 1.2.5 on x86_64: when the month in an
> Mm.n.d daylight-saving rule is out of range, localtime_r() can
> read outside the bounds of a month lookup table.
>
>
> In src/time/__tz.c:347, rule_to_secs() calls:
> t += __month_to_secs(m-1, is_leap);
>
>
> Because m is not checked against the valid range of 1 through 12,
> m-1 can be outside the bounds of the 12-element table that
> __month_to_secs() indexes in src/time/__month_to_secs.c.
I suppose we need to decide what should happen on invalid TZ strings.
POSIX specifies:
"The application shall ensure that the value of TZ is in one of
the three formats (spaces inserted for clarity):
..."
So there isn't a constraint on implementations as to what they should
do when it's invalid.
I suppose we can make it ignore them and give UTC. Any objections to
that?
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.