Re: BUG #18200: Undefined behaviour in interval_div

Dean Rasheed <dean.a.rasheed@gmail.com>

From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-11-15T22:41:01Z
Lists: pgsql-bugs

Attachments

On Wed, 15 Nov 2023 at 18:14, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
>
> looking at
> interval_mul(), there is nothing to prevent integer overflow when
> cascading down, so additional checks are needed there too (in both
> functions).
>

Here's a patch doing that. I'm inclined to back-patch this, because
this seems like something that's quite easily triggered, and returning
bogus results is not good.

Regards,
Dean

Commits

  1. Guard against overflow in interval_mul() and interval_div().