Re: Fix overflow in DecodeInterval
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Joseph Koshakow <koshy44@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@lists.postgresql.org
Date: 2022-02-13T03:51:50Z
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
Commits
-
Fix portability issues in datetime parsing.
- 591e088dd5b3 15.0 landed
-
Fix overflow hazards in interval input and output conversions.
- e39f99046710 15.0 landed
-
Add a couple more tests for interval input decoding.
- 1b208ebaf14e 15.0 landed