Avoid integer overflow hazard in interval_time().
Dean Rasheed <dean.a.rasheed@gmail.com>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/date.c | modified | +3 −12 |
| src/test/regress/expected/horology.out | modified | +12 −0 |
| src/test/regress/sql/horology.sql | modified | +2 −0 |
Discussion
- Infinite Interval 104 messages · 2022-12-10 → 2023-11-18