Re: BUG #18614: [ECPG] out of bound in DecodeDateTime

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: p(dot)nekrasov(at)fobos-nt(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18614: [ECPG] out of bound in DecodeDateTime
Date: 2024-10-17 17:29:03
Message-ID: ZxFJX8Jjoy8T-67v@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Oct 16, 2024 at 09:18:10AM +0900, Michael Paquier wrote:
> 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.

Added in the attached patch. Is the output correct?

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

When a patient asks the doctor, "Am I going to die?", he means
"Am I going to die soon?"

Attachment Content-Type Size
ecpg.diff text/x-diff 4.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-10-17 20:30:17 Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault
Previous Message Tom Lane 2024-10-17 15:03:13 Re: BUG #18662: ORDER BY after GROUPING SETS does not order correctly for certain WHERE condition