pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Bruce Momjian <bruce@momjian.us>
Cc: p.nekrasov@fobos-nt.ru
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18614: [ECPG] out of bound in DecodeDateTime
Date: Fri, 18 Oct 2024 14:51:32 +0900
Message-ID: <ZxH3ZGK19VxTJcpU@paquier.xyz> (raw)
In-Reply-To: <ZxFJX8Jjoy8T-67v@momjian.us>
References: <18614-6bbe00117352309e@postgresql.org>
	<Zw2Su7kkYYF8nHQY@momjian.us>
	<Zw8GQrLHlgJlz3Qc@paquier.xyz>
	<ZxFJX8Jjoy8T-67v@momjian.us>

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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (12+ messages)  latest in thread

Message-ID: <ZxH3ZGK19VxTJcpU@paquier.xyz>
Permalink:  ../ZxH3ZGK19VxTJcpU@paquier.xyz/
Also on:    postgresql.org/message-id/ZxH3ZGK19VxTJcpU@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, bruce@momjian.us, p.nekrasov@fobos-nt.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18614: [ECPG] out of bound in DecodeDateTime
  In-Reply-To: <ZxH3ZGK19VxTJcpU@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox