Re: Fix overflow in DecodeInterval

From: Andres Freund <andres(at)anarazel(dot)de>
To: Joseph Koshakow <koshy44(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix overflow in DecodeInterval
Date: 2022-02-13 03:51:50
Message-ID: 20220213035150.wusl6mmbeb3m3jpy@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-02-12 21:16:05 -0500, Joseph Koshakow wrote:
> I've attached the patch below.

Any reason for using int return types?

> +/* As above, but initial val produces years */
> +static int
> +AdjustYears(int val, struct pg_tm *tm, int multiplier)
> +{
> + int years;
> + if (pg_mul_s32_overflow(val, multiplier, &years))
> + return 1;
> + if (pg_add_s32_overflow(tm->tm_year, years, &tm->tm_year))
> + return 1;
> + return 0;
> }

particularly since the pg_*_overflow stuff uses bool?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-02-13 03:59:56 Re: Mark all GUC variable as PGDLLIMPORT
Previous Message Andres Freund 2022-02-13 03:43:37 Re: Adding CI to our tree