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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bruce Momjian <bruce(at)momjian(dot)us>
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-18 05:51:32
Message-ID: ZxH3ZGK19VxTJcpU@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Oct 17, 2024 at 01:29:03PM -0400, Bruce Momjian wrote:
> Added in the attached patch. Is the output correct?

Well, no. The result in the regression test output you are producing
is a consequence that PGTYPEStimestamp_from_asc() returns
PGTYPES_TS_BAD_TIMESTAMP as errno with 0 as result. Hence, after
applying an offset this prints a timestamp with year 2000. What this
should report in the regression test output is the information about
the error happening, so the output that makes no sense because the
timestamp could not be understood.

> + ts1 = PGTYPEStimestamp_from_asc("AM95000062", NULL);
> + text = PGTYPEStimestamp_to_asc(ts1);
> + printf("timestamp_to_asc4: %s\n", text);
> + PGTYPESchar_free(text);
> +
> /* abc-03:10:35-def-02/11/94-gh */
> /* 12345678901234567890123456789 */

It is not entirely the fault of this patch, because the same error is
done a couple of lines above when using an incorrect hour number with
timestamp_to_asc3. The correct thing to do would be in the lines of
what num_test2.pgc does with its check_errno(), I think where we'd
check for the errno returned by PGTYPEStimestamp_from_asc() and
printf() its information in the output of the test. And we should do
that for both the old timestamp_to_asc3 and your new timestamp_to_asc4
if we want to be completely correct.
--
Michael

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2024-10-18 06:14:06 Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault
Previous Message Amit Langote 2024-10-18 05:03:58 Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault