pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid integer overflow hazard in interval_time().
Date: Thu, 09 Nov 2023 12:11:32 +0000
Message-ID: <E1r13si-004eQn-Cr@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3850d4dec1d91c4fdce274f42986840444d5593e

Modified Files
--------------
src/backend/utils/adt/date.c           | 15 +++------------
src/test/regress/expected/horology.out | 12 ++++++++++++
src/test/regress/sql/horology.sql      |  2 ++
3 files changed, 17 insertions(+), 12 deletions(-)



Message-ID: <E1r13si-004eQn-Cr@gemulon.postgresql.org>
Permalink:  ../E1r13si-004eQn-Cr@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1r13si-004eQn-Cr@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Avoid integer overflow hazard in interval_time().
  In-Reply-To: <E1r13si-004eQn-Cr@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox