mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -1929,6 +1929,12 @@ SELECT to_char('100'::numeric, 'FM999');
|
||||
100
|
||||
(1 row)
|
||||
|
||||
SELECT to_char('12345678901'::float8, 'FM9999999999D9999900000000000000000');
|
||||
to_char
|
||||
-----------------
|
||||
##########.####
|
||||
(1 row)
|
||||
|
||||
-- Check parsing of literal text in a format string
|
||||
SELECT to_char('100'::numeric, 'foo999');
|
||||
to_char
|
||||
|
@@ -979,6 +979,7 @@ FROM v;
|
||||
SELECT to_char('100'::numeric, 'FM999.9');
|
||||
SELECT to_char('100'::numeric, 'FM999.');
|
||||
SELECT to_char('100'::numeric, 'FM999');
|
||||
SELECT to_char('12345678901'::float8, 'FM9999999999D9999900000000000000000');
|
||||
|
||||
-- Check parsing of literal text in a format string
|
||||
SELECT to_char('100'::numeric, 'foo999');
|
||||
|
Reference in New Issue
Block a user