summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2021-01-02 13:25:41 (EST)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2021-01-02 14:55:36 (EST)
commit75dd10693b6ced4f4d55ce6f374807e306de5783 (patch)
tree80106808c05e4ef23c72aa26746e09ffb5233c10
parentda66db89bd5c26c6731b77e3f8616e660529812d (diff)
ob_*_gmtime(): Don't freeze on New Year's Day
And add test cases to confirm the resolution of this bug and the one fixed by commit 83bee70f80d8c98b875c943297b0049eae7d6d22.
-rw-r--r--NEWS6
-rw-r--r--lib/time.sh2
-rwxr-xr-xtests/lib/ob_iso8601_gmtime.sh5
3 files changed, 11 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 5a78d08..93303d5 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,12 @@ Utilities:
contain dependency restrictions or newline characters that are
passed through to the binary package's control file.
+libopkbuild:
+
+ * ob_iso8601_gmtime() and ob_touch_t_gmtime() no longer trigger an
+ infinite loop when passed times on January 1. This time bomb broke
+ ob-buildopk one day every year.
+
opkbuild version 4.2.1
----------------------
diff --git a/lib/time.sh b/lib/time.sh
index 5100b04..910d825 100644
--- a/lib/time.sh
+++ b/lib/time.sh
@@ -158,7 +158,7 @@ _ob_gmtime()
while :; do
_ob_is_leap_year ${year} && days_in_year=366 || days_in_year=365
- [ ${timep} -le ${days_in_year} ] && break
+ [ ${timep} -lt ${days_in_year} ] && break
: $((timep -= ${days_in_year}))
: $((year += 1))
done
diff --git a/tests/lib/ob_iso8601_gmtime.sh b/tests/lib/ob_iso8601_gmtime.sh
index 840b378..d318961 100755
--- a/tests/lib/ob_iso8601_gmtime.sh
+++ b/tests/lib/ob_iso8601_gmtime.sh
@@ -23,7 +23,7 @@ set -eu
. "${TOP_SRCDIR}/tests/aux/common.sh"
. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
-plan_ 7
+plan_ 10
tst()
{
@@ -40,4 +40,7 @@ tst 108123 '1970-01-02T06:02:03Z'
tst 41877296 '1971-04-30T16:34:56Z'
tst 762480000 '1994-03-01T00:00:00Z'
tst 962443230 '2000-07-01T09:20:30Z'
+tst 1607419408 '2020-12-08T09:23:28Z'
+tst 1609459199 '2020-12-31T23:59:59Z'
+tst 1609510819 '2021-01-01T14:20:19Z'
tst 2147483648 '2038-01-19T03:14:08Z'