pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix contrib/seg to be more wary of long input numbers. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c8314d62a9bda3cb55dfea90ec5130713288058a 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/701c881f782b93ee29587112390bd3bfe035e78d 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0ff4056b8ce994e2932260c9f194675769b3d2e5 Modified Files -------------- contrib/seg/expected/seg.out | 7 +++++++ contrib/seg/expected/seg_1.out | 7 +++++++ contrib/seg/seg.c | 8 ++++++-- contrib/seg/segparse.y | 22 +++++++++++++++++----- contrib/seg/sql/seg.sql | 3 +++ 5 files changed, 40 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b87037b373cf5605e6755e50c62348337a0d32c8 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f489b480f4aa8b4db4858a7bef1b42c984992c8a 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix contrib/seg to be more wary of long input numbers. @ 2022-12-21 22:52 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-12-21 22:52 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-12-21 22:52 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us> 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us> 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us> 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us> 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us> 2022-12-21 22:52 pgsql: Fix contrib/seg to be more wary of long input numbers. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox