pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix corner case bug in numeric to_char() some more.
Date: Tue, 14 Mar 2023 23:17:46 +0000
Message-ID: <E1pcDtq-003ZWD-5V@gemulon.postgresql.org> (raw)

Fix corner case bug in numeric to_char() some more.

The band-aid applied in commit f0bedf3e4 turns out to still need
some work: it made sure we didn't set Np->last_relevant too small
(to the left of the decimal point), but it didn't prevent setting
it too large (off the end of the partially-converted string).
This could result in fetching data beyond the end of the allocated
space, which with very bad luck could cause a SIGSEGV, though
I don't see any hazard of interesting memory disclosure.

Per bug #17839 from Thiago Nunes.  The bug's pretty ancient,
so back-patch to all supported versions.

Discussion: https://postgr.es/m/17839-aada50db24d7b0da@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b081fe4199b69dc561f7d31c6a82b3ad996f657f

Modified Files
--------------
src/backend/utils/adt/formatting.c    | 11 +++++++++--
src/test/regress/expected/numeric.out |  6 ++++++
src/test/regress/sql/numeric.sql      |  1 +
3 files changed, 16 insertions(+), 2 deletions(-)



view thread (12+ messages)  latest in thread

Message-ID: <E1pcDtq-003ZWD-5V@gemulon.postgresql.org>
Permalink:  ../E1pcDtq-003ZWD-5V@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pcDtq-003ZWD-5V@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix corner case bug in numeric to_char() some more.
  In-Reply-To: <E1pcDtq-003ZWD-5V@gemulon.postgresql.org>

* 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