From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix contrib/seg to be more wary of long input numbers. |
Date: | 2022-12-21 22:52:06 |
Message-ID: | E1p87wT-004moH-FQ@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix contrib/seg to be more wary of long input numbers.
seg stores the number of significant digits in an input number
in a "char" field. If char is signed, and the input is more than
127 digits long, the count can read out as negative causing
seg_out() to print garbage (or, if you're really unlucky,
even crash).
To fix, clamp the digit count to be not more than FLT_DIG.
(In theory this loses some information about what the original
input was, but it doesn't seem like useful information; it would
not survive dump/restore in any case.)
Also, in case there are stored values of the seg type containing
bad data, add a clamp in seg_out's restore() subroutine.
Per bug #17725 from Robins Tharakan. It's been like this
forever, so back-patch to all supported branches.
Discussion: https://postgr.es/m/17725-0a09313b67fbe86e@postgresql.org
Branch
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d35f1d485c392ce058382794742ce246e47643ec
Modified Files
--------------
contrib/seg/expected/seg.out | 7 +++++++
contrib/seg/seg.c | 8 ++++++--
contrib/seg/segparse.y | 22 +++++++++++++++++-----
contrib/seg/sql/seg.sql | 3 +++
4 files changed, 33 insertions(+), 7 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2022-12-22 00:32:30 | pgsql: Add palloc_aligned() to allow aligned memory allocations |
Previous Message | Andrew Dunstan | 2022-12-21 22:00:32 | pgsql: Introduce float4in_internal |