Skip site navigation (1) Skip section navigation (2)

pg_dump: fix crash on error

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: pg_dump: fix crash on error
Date: 2005-07-27 01:41:30
Message-ID: 42E6E64A.5040902@samurai.com (view raw or flat)
Thread:
Lists: pgsql-patches
If pg_dump fails to connect to Postgres, it attempts to print an error 
message in ConnectDatabase():

/* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD)
     die_horribly(AH, modulename,
                  "connection to database \"%s\" failed: %s",
                  dbname, PQerrorMessage(AH->connection));

But if no database is explicitly specified, `dbname' is NULL, and libc 
is entitled to crash if you pass a NULL pointer to it for a %s 
formatting sequence (it actually does crash on Solaris, for example -- 
per report from Omar Kilani).

Attached is a patch that fixes this by just removing `dbname' from the 
error message, as PQerrorMessage() should provide enough information.

Barring any objections, I'll apply this to HEAD and back branches within 
24 hours.

-Neil

Attachment: pg_dump_null_pointer_printf-1.patch
Description: text/x-patch (1.0 KB)

Responses

pgsql-patches by date

Next:From: Gavin SherryDate: 2005-07-27 03:47:25
Subject: Duplicate object names in GRANT
Previous:From: Rocco AltierDate: 2005-07-26 18:39:42
Subject: Re: Proposed patch to remove .so pattern rules from platform Makefiles

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group