93dc2d
commit 515a6f53cd984d5e6e374fbee52772f967fc3c73
93dc2d
Author: Paul Eggert <eggert@cs.ucla.edu>
93dc2d
Date:   Mon Sep 13 22:49:45 2021 -0700
93dc2d
93dc2d
    Fix subscript error with odd TZif file [BZ #28338]
93dc2d
    
93dc2d
    * time/tzfile.c (__tzfile_compute): Fix unlikely off-by-one bug
93dc2d
    that accessed before start of an array when an oddball-but-valid
93dc2d
    TZif file was queried with an unusual time_t value.
93dc2d
    
93dc2d
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
93dc2d
    (cherry picked from commit 645277434a42efc547d2cac8bfede4da10b4049f)
93dc2d
93dc2d
diff --git a/time/tzfile.c b/time/tzfile.c
93dc2d
index 4377018a55936389..190a777152b31cee 100644
93dc2d
--- a/time/tzfile.c
93dc2d
+++ b/time/tzfile.c
93dc2d
@@ -765,8 +765,7 @@ __tzfile_compute (__time64_t timer, int use_localtime,
93dc2d
   *leap_correct = leaps[i].change;
93dc2d
 
93dc2d
   if (timer == leaps[i].transition /* Exactly at the transition time.  */
93dc2d
-      && ((i == 0 && leaps[i].change > 0)
93dc2d
-	  || leaps[i].change > leaps[i - 1].change))
93dc2d
+      && (leaps[i].change > (i == 0 ? 0 : leaps[i - 1].change)))
93dc2d
     {
93dc2d
       *leap_hit = 1;
93dc2d
       while (i > 0