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

Bruce Momjian <bruce@momjian.us>

From: Bruce Momjian <bruce@momjian.us>
To: p.nekrasov@fobos-nt.ru, pgsql-bugs@lists.postgresql.org
Date: 2024-10-14T21:52:59Z
Lists: pgsql-bugs

Attachments

On Thu, Sep 12, 2024 at 08:54:42AM +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      18614
> Logged by:          Pavel Nekrasov
> Email address:      p.nekrasov@fobos-nt.ru
> PostgreSQL version: 17rc1
> Operating system:   Alt 10
> Description:        
> 
> in the line ```if (tm->tm_mday < 1 || tm->tm_mday >
> day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) ``` tm->tm_mon may be equal to
> 0, which will result in reading by indexes -1
> 
> this is possible when calling PGTYPESdate_from_asc or
> PGTYPEStimestamp_from_asc with "str" equal, for example, "AM95000062"

Yes, I agree.  Attached is a non-word-wrapped patch that I plan to apply
to all supported PG versions.

-- 
  Bruce Momjian  <bruce@momjian.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?"

Commits

  1. ecpg: Fix out-of-bound read in DecodeDateTime()