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-18T05:51:32Z
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
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