diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-06-16 12:17:03 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-06-16 12:17:11 -0400 |
commit | 4f5995dd983db31bce347411c16ecc7319a2d9af (patch) | |
tree | 3ae5c8b0d9838d505ecfe65e60f604c2871f0d7b /src | |
parent | 455812da4820b21c938fac840c17e68d4ec856a9 (diff) | |
download | postgresql-4f5995dd983db31bce347411c16ecc7319a2d9af.tar.gz postgresql-4f5995dd983db31bce347411c16ecc7319a2d9af.zip |
Avoid crash in "postgres -C guc" for a GUC with a null string value.
Emit "(null)" instead, which was the behavior all along on platforms
that don't crash, eg OS X. Per report from Jehan-Guillaume de Rorthais.
Back-patch to 9.2 where -C option was introduced.
Michael Paquier
Report: <20160615204036.2d35d86a@firost>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/postmaster.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 7e3fd0d3fde..3cfd5b8a57e 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -821,10 +821,14 @@ PostmasterMain(int argc, char *argv[]) if (output_config_variable != NULL) { /* - * permission is handled because the user is reading inside the data - * dir + * "-C guc" was specified, so print GUC's value and exit. No extra + * permission check is needed because the user is reading inside the + * data dir. */ - puts(GetConfigOption(output_config_variable, false, false)); + const char *config_val = GetConfigOption(output_config_variable, + false, false); + + puts(config_val ? config_val : "(null)"); ExitPostmaster(0); } |