postgresql/src/backend
Tom Lane 7769fc000a 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
2017-09-27 17:05:53 -04:00
..
access Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:43 -04:00
bootstrap Sync process names between ps and pg_stat_activity 2017-09-20 08:59:03 -04:00
catalog Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:43 -04:00
commands Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:43 -04:00
executor Make construct_[md_]array return a valid empty array for zero-size input. 2017-09-25 11:55:24 -04:00
foreign Abstract logic to allow for multiple kinds of child rels. 2017-04-03 22:41:31 -04:00
lib Fix uninitialized variable in dshash.c. 2017-09-18 17:43:37 -07:00
libpq Refactor new file permission handling 2017-09-23 10:16:18 -04:00
main Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
nodes Add inline murmurhash32(uint32) function. 2017-09-22 13:38:42 -07:00
optimizer Quieten warnings about unused variables 2017-09-21 08:41:14 -04:00
parser After a MINVALUE/MAXVALUE bound, allow only more of the same. 2017-09-15 21:15:55 -04:00
po Translation updates 2017-08-07 13:55:34 -04:00
port Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postmaster Improve memory management in autovacuum.c. 2017-09-23 13:28:16 -04:00
regex Mop-up for commit 85feb77aa0. 2017-09-22 11:35:12 -04:00
replication Handle heap rewrites better in logical replication 2017-09-26 10:13:43 -04:00
rewrite Message style fixes 2017-09-11 11:21:27 -04:00
snowball Initial pgindent run with pg_bsd_indent version 2.0. 2017-06-21 14:39:04 -04:00
statistics Remove obsolete comments about functional dependencies 2017-07-26 11:40:39 -04:00
storage Fix failure-to-read-man-page in commit 899bd785c. 2017-09-26 13:42:53 -04:00
tcop Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:43 -04:00
tsearch Mop-up for commit 85feb77aa0. 2017-09-22 11:35:12 -04:00
utils Fix behavior when converting a float infinity to numeric. 2017-09-27 17:05:53 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Add ICU_CFLAGS to global CPPFLAGS 2017-06-12 15:57:22 -04:00
Makefile Inject $(ICU_LIBS) regardless of platform. 2017-08-20 21:22:18 -07:00
nls.mk Translation updates 2017-05-15 12:19:54 -04:00