BUG #18614: [ECPG] out of bound in DecodeDateTime
От | PG Bug reporting form |
---|---|
Тема | BUG #18614: [ECPG] out of bound in DecodeDateTime |
Дата | |
Msg-id | 18614-6bbe00117352309e@postgresql.org обсуждение исходный текст |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 18614 Logged by: Pavel Nekrasov Email address: p.nekrasov@fobos-nt.ru PostgreSQL version: 17rc1 Operating system: Alt 10 Description: in the line ```if (tm->tm_mday < 1 || tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) ``` tm->tm_mon may be equal to 0, which will result in reading by indexes -1 this is possible when calling PGTYPESdate_from_asc or PGTYPEStimestamp_from_asc with "str" equal, for example, "AM95000062" Patch: --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -2327,10 +2327,9 @@ DecodeDateTime(char **field, int *ftype, int nf, return ((fmask & DTK_TIME_M) == DTK_TIME_M) ? 1 : -1; /* - * check for valid day of month, now that we know for sure the month - * and year... + * check for valid day of month and month, now that we know for sure the 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; /*
В списке pgsql-bugs по дате отправления: