]> granicus.if.org Git - postgresql/commitdiff
Avoid crash in "postgres -C guc" for a GUC with a null string value.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 16 Jun 2016 16:17:03 +0000 (12:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 16 Jun 2016 16:17:25 +0000 (12:17 -0400)
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>

src/backend/postmaster/postmaster.c

index b8b51f1e6350473d7f7cc375aa04882ff733bd11..6e29609ff6d11915640a6f5157060cbd51fe2183 100644 (file)
@@ -783,10 +783,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);
        }