]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix corner case bug in numeric to_char() some more.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Mar 2023 23:17:31 +0000 (19:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Mar 2023 23:17:31 +0000 (19:17 -0400)
commita67c75f8258742945f4f3703126a1222adeeb85b
treecc6c70ef2ddfbba0104eb68468ced10f08203426
parent3b459444301c4c40e8d978ef6025c7177c85c017
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
src/backend/utils/adt/formatting.c
src/test/regress/expected/numeric.out
src/test/regress/sql/numeric.sql