git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: a4f7d33) | patch
Avoid integer overflow hazard in interval_time().
Thu, 9 Nov 2023 12:10:14 +0000 (12:10 +0000)
Thu, 9 Nov 2023 12:10:14 +0000 (12:10 +0000)
commit 3850d4dec1d91c4fdce274f42986840444d5593e
Avoid integer overflow hazard in interval_time().

When casting an interval to a time, the original code suffered from
64-bit integer overflow for inputs with a sufficiently large negative
"time" field, leading to bogus results.

Fix by rewriting the algorithm in a simpler form, that more obviously
cannot overflow. While at it, improve the test coverage to include
negative interval inputs.

Discussion: https://postgr.es/m/CAEZATCXoUKHkcuq4q63hkiPsKZJd0kZWzgKtU%2BNT0aU4wbf_Pw%40mail.gmail.com
src/backend/utils/adt/date.c diff | blob | blame | history
src/test/regress/expected/horology.out diff | blob | blame | history
src/test/regress/sql/horology.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /