Re: BUG #18614: [ECPG] out of bound in DecodeDateTime
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Bruce Momjian <bruce@momjian.us>
Cc: p.nekrasov@fobos-nt.ru, pgsql-bugs@lists.postgresql.org
Date: 2024-10-16T00:18:10Z
Lists: pgsql-bugs
On Mon, Oct 14, 2024 at 05:52:59PM -0400, Bruce Momjian wrote: > /* > - * check for valid day of month, now that we know for sure the month > + * check for valid day of month and month, now that we know for sure the month > * and year... > */ > - if (tm->tm_mday < 1 || tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) > + if (tm->tm_mon < 1 || tm->tm_mday < 1 || tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) > return -1; I would suggest adding a test. This is tricky enough and really easy to miss, even if ECPG is not that touched these days. There are a lot of callers of PGTYPEStimestamp_from_asc() in dt_test.pgc that do sanity checks on such inputs. -- Michael
Commits
-
ecpg: Fix out-of-bound read in DecodeDateTime()
- 9ecfd8a48adf 12.21 landed
- fcafbaadf7e5 13.17 landed
- 9a51d4af12a7 14.14 landed
- 335501fb2b80 15.9 landed
- a1e613b81aa0 16.5 landed
- 2c37cb26f8af 17.1 landed
- a0bff38d133a 18.0 landed