pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: t.larionov@postgrespro.ru
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16953: OOB access while converting "interval" to char
Date: Fri, 9 Apr 2021 19:58:51 +0900
Message-ID: <YHAza+N74LHygGnB@paquier.xyz> (raw)
In-Reply-To: <20210409104246.vkeef6rbyevq46f3@nol>
References: <16953-f255a18f8c51f1d5@postgresql.org>
	<20210407120856.3rjxxnnzzxn74vyv@nol>
	<YG7YTjuZXylrjGAv@paquier.xyz>
	<20210408110403.wr3d552xilqsx4us@nol>
	<YG7q8YcvFcXCAbAH@paquier.xyz>
	<20210409104246.vkeef6rbyevq46f3@nol>

On Fri, Apr 09, 2021 at 06:42:46PM +0800, Julien Rouhaud wrote:
> I'm not sure what you mean by that.  We receive a pg_tm struct which can't
> contain more than 12 in tm_mon right?  And actually for intervals it will
> reduce "12 months" to "1 year 0 month", so to_char previously didn't report
> anything for 12 months either.

I did not take the time to look in details, but for reference I just
imagined that a formula like this one would give pretty much the
position in rm_months_upper:
M_PER_Y - ((tm_mon % M_PER_Y) + M_PER_Y) % M_PER_Y

> Hearing no other opinion I went with -1 -> december and so on in attached v2.
> I also fixed the "[-]12 months" case and updated the regression tests.  Given
> the extra code needed to deduce the correct array position I factorized DCH_RM
> and DCH_rm.

Yep.  The regression tests show what I would expect.  I'll check in
details later.
--
Michael

Attachments:

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

view thread (9+ messages)  latest in thread

Message-ID: <YHAza+N74LHygGnB@paquier.xyz>
Permalink:  ../YHAza+N74LHygGnB@paquier.xyz/
Also on:    postgresql.org/message-id/YHAza+N74LHygGnB@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, rjuju123@gmail.com, t.larionov@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16953: OOB access while converting "interval" to char
  In-Reply-To: <YHAza+N74LHygGnB@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