]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix subscript error with odd TZif file [BZ #28338]
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Sep 2021 05:49:45 +0000 (22:49 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 7 Oct 2021 14:09:16 +0000 (11:09 -0300)
* time/tzfile.c (__tzfile_compute): Fix unlikely off-by-one bug
that accessed before start of an array when an oddball-but-valid
TZif file was queried with an unusual time_t value.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
time/tzfile.c

index 4377018a559363891829fb400ea3e10a0e110d05..190a777152b31cee5d90d2dc6bc784cd2c904d97 100644 (file)
@@ -765,8 +765,7 @@ __tzfile_compute (__time64_t timer, int use_localtime,
   *leap_correct = leaps[i].change;
 
   if (timer == leaps[i].transition /* Exactly at the transition time.  */
-      && ((i == 0 && leaps[i].change > 0)
-         || leaps[i].change > leaps[i - 1].change))
+      && (leaps[i].change > (i == 0 ? 0 : leaps[i - 1].change)))
     {
       *leap_hit = 1;
       while (i > 0