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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix corner case bug in numeric to_char() some more.
Date: 2023-03-14 23:17:46
Message-ID: E1pcDtq-003ZWF-6C@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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
------
REL_15_STABLE

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

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2023-03-15 00:45:08 pgsql: Fix waitpid() emulation on Windows.
Previous Message Tom Lane 2023-03-14 20:09:15 pgsql: Allow pg_dump to include/exclude child tables automatically.