From 63dd5efa729e314cd2e8074fc723c7488693f381 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Thu, 7 Dec 2023 15:00:47 +0100 Subject: [PATCH] libc: fix post-2100 infinite-loop on 32-bit The call of `mktime`/`timegm` with a broken down time after year 2100 led to an infinite-loop on 32bit. genodelabs/genode#3707 --- repos/libports/ports/libc.hash | 2 +- .../src/lib/libc/patches/mktime.patch | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/repos/libports/ports/libc.hash b/repos/libports/ports/libc.hash index 04993bcf7a..e90372ce28 100644 --- a/repos/libports/ports/libc.hash +++ b/repos/libports/ports/libc.hash @@ -1 +1 @@ -dfcf0321f6f20fb8051954bc3fb4e661467a3434 +b36b17e21acc3a6b70bc550e19d08abbb15db71a diff --git a/repos/libports/src/lib/libc/patches/mktime.patch b/repos/libports/src/lib/libc/patches/mktime.patch index 0860f3e1ce..d85ec92d82 100644 --- a/repos/libports/src/lib/libc/patches/mktime.patch +++ b/repos/libports/src/lib/libc/patches/mktime.patch @@ -13,6 +13,25 @@ index 3c66924..05c01ae 100644 for ( ; ; ) { t = lo / 2 + hi / 2; if (t < lo) +@@ -1955,14 +2251,14 @@ time2sub(struct tm *const tmp, + } else dir = tmcomp(&mytm, &yourtm); + if (dir != 0) { + if (t == lo) { +- ++t; +- if (t <= lo) ++ if (t == TIME_T_MAX) + return WRONG; ++ ++t; + ++lo; + } else if (t == hi) { +- --t; +- if (t >= hi) ++ if (t == TIME_T_MIN) + return WRONG; ++ --t; + --hi; + } + if (lo > hi) diff --git a/src/lib/libc/contrib/tzcode/stdtime/private.h b/src/lib/libc/contrib/tzcode/stdtime/private.h index 354a78b..8300ba0 100644 --- src/lib/libc/contrib/tzcode/stdtime/private.h