]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
parse-datetime: Prefer ckd_add to checking overflow by hand.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 15 Feb 2026 23:18:37 +0000 (15:18 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 15 Feb 2026 23:18:37 +0000 (15:18 -0800)
* lib/parse-datetime.y (time_overflow): Use ckd_add to check for
overflow.

ChangeLog
lib/parse-datetime.y

index 85d0713c1609c708e9c14cf87d4fa1b61b6852cd..b1725725fffcb36d7d8521aa732c1e74b4578d6d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-02-15  Collin Funk  <collin.funk1@gmail.com>
+
+       parse-datetime: Prefer ckd_add to checking overflow by hand.
+       * lib/parse-datetime.y (time_overflow): Use ckd_add to check for
+       overflow.
+
 2026-02-14  Paul Eggert  <eggert@cs.ucla.edu>
 
        fchownat: port to IBM XL C for AIX 16.1
index 8d396b1273210bd5d2ff2cae948d64fcae86c9c5..6732bf1520633f481e0a32aeb520d3725f3b357b 100644 (file)
@@ -99,8 +99,8 @@ static_assert (TYPE_MAXIMUM (time_t) <= INTMAX_MAX);
 static bool
 time_overflow (intmax_t n)
 {
-  return ! ((TYPE_SIGNED (time_t) ? TYPE_MINIMUM (time_t) <= n : 0 <= n)
-            && n <= TYPE_MAXIMUM (time_t));
+  time_t t;
+  return ckd_add (&t, n, 0);
 }
 
 /* Convert a possibly-signed character to an unsigned character.  This is