aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-03-10 12:58:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-03-10 12:58:52 -0400
commitd8f8183c04671b0ffe26ae6f8aee9e50df5fff1e (patch)
tree94579b47ed6854d8db47334f9fc72a0f64fee8aa /src/backend/utils
parenta2c59a28c738959e9a5e7d8e95140ff89787a95c (diff)
downloadpostgresql-d8f8183c04671b0ffe26ae6f8aee9e50df5fff1e.tar.gz
postgresql-d8f8183c04671b0ffe26ae6f8aee9e50df5fff1e.zip
Disallow NaN as a value for floating-point GUCs.
None of the code that uses GUC values is really prepared for them to hold NaN, but parse_real() didn't have any defense against accepting such a value. Treat it the same as a syntax error. I haven't attempted to analyze the exact consequences of setting any of the float GUCs to NaN, but since they're quite unlikely to be good, this seems like a back-patchable bug fix. Note: we don't need an explicit test for +-Infinity because those will be rejected by existing range checks. I added a regression test for that in HEAD, but not older branches because the spelling of the value in the error message will be platform-dependent in branches where we don't always use port/snprintf.c. Discussion: https://postgr.es/m/1798.1552165479@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/misc/guc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 427d807ada1..0c9ed0908f6 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -5327,6 +5327,10 @@ parse_real(const char *value, double *result)
if (endptr == value || errno == ERANGE)
return false;
+ /* reject NaN (infinities will fail range checks later) */
+ if (isnan(val))
+ return false;
+
/* allow whitespace after number */
while (isspace((unsigned char) *endptr))
endptr++;