You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: contrib/seg/expected/seg.out
+7
Original file line number
Diff line number
Diff line change
@@ -256,6 +256,13 @@ SELECT '12.34567890123456'::seg AS seg;
256
256
12.3457
257
257
(1 row)
258
258
259
+
-- Same, with a very long input
260
+
SELECT '12.3456789012345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::seg AS seg;
Copy file name to clipboardExpand all lines: contrib/seg/sql/seg.sql
+3
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,9 @@ SELECT '3.400e5'::seg AS seg;
60
60
-- Digits truncated
61
61
SELECT'12.34567890123456'::seg AS seg;
62
62
63
+
-- Same, with a very long input
64
+
SELECT'12.3456789012345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::seg AS seg;
0 commit comments