git: e99479f817c4 - releng/13.3 - tzcode: Fix overflow handling in TZ parser.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Fri, 23 Feb 2024 11:41:32 UTC
The branch releng/13.3 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=e99479f817c4714d396de1d403daa6f9bc3a32bb

commit e99479f817c4714d396de1d403daa6f9bc3a32bb
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-02-18 09:48:08 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-02-23 11:41:25 +0000

    tzcode: Fix overflow handling in TZ parser.
    
    Obtained from:  upstream 9fc11a27
    MFC after:      1 week
    PR:             276281
    Approved by:    re (cperciva)
    
    (cherry picked from commit 1365bb722af1365baee6ea1e3d44917533908d53)
    (cherry picked from commit beb958dca02abf79a2172e702c2d24bbccde60fa)
---
 contrib/tzcode/localtime.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 3bf9378fe673..8bf4fcb17d2d 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -1277,11 +1277,13 @@ tzparse(const char *name, struct state *sp, struct state *basep)
 			do {
 			  int_fast32_t yearsecs
 			    = year_lengths[isleap(yearbeg - 1)] * SECSPERDAY;
+			  time_t janfirst1 = janfirst;
 			  yearbeg--;
-			  if (increment_overflow_time(&janfirst, -yearsecs)) {
+			  if (increment_overflow_time(&janfirst1, -yearsecs)) {
 			    janoffset = -yearsecs;
 			    break;
 			  }
+			  janfirst = janfirst1;
 			} while (atlo < janfirst
 				 && EPOCH_YEAR - YEARSPERREPEAT / 2 < yearbeg);