pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix behavior when converting a float infinity to numeric. 7+ messages / 1 participants [nested] [flat]
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c38575edce0d75d4464af7b4153ba0cbf654fd9d Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ad56dbd6c0b87e95fb1cf45025bb7dd8152a9f59 Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7769fc000aa3b959d3e1c7d7c3c2555aba7722c3 Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL9_2_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/72d4fd08ea63e2855c0b54317a09047455ff8369 Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL9_3_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2e82fba0e6a9f5d3253b89e5f2de2b1bf042d71c Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/def03e4bfe30c230d7532f2d7cfe5d7485a658a8 Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix behavior when converting a float infinity to numeric. @ 2017-09-27 21:06 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2017-09-27 21:06 UTC (permalink / raw) To: pgsql-committers Fix behavior when converting a float infinity to numeric. float8_numeric() and float4_numeric() failed to consider the possibility that the input is an IEEE infinity. The results depended on the platform-specific behavior of sprintf(): on most platforms you'd get something like ERROR: invalid input syntax for type numeric: "inf" but at least on Windows it's possible for the conversion to succeed and deliver a finite value (typically 1), due to a nonstandard output format from sprintf and lack of syntax error checking in these functions. Since our numeric type lacks the concept of infinity, a suitable conversion is impossible; the best thing to do is throw an explicit error before letting sprintf do its thing. While at it, let's use snprintf not sprintf. Overrunning the buffer should be impossible if sprintf does what it's supposed to, but this is cheap insurance against a stack smash if it doesn't. Problem reported by Taiki Kondo. Patch by me based on fix suggestion from KaiGai Kohei. Back-patch to all supported branches. Discussion: https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/07ea925e20ee80898638800c8479b48e7e97d431 Modified Files -------------- src/backend/utils/adt/numeric.c | 14 ++++++++++++-- src/test/regress/expected/numeric.out | 21 +++++++++++++++++++++ src/test/regress/sql/numeric.sql | 8 ++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2017-09-27 21:06 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. Tom Lane <tgl@sss.pgh.pa.us> 2017-09-27 21:06 pgsql: Fix behavior when converting a float infinity to numeric. 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