Lists: | pgsql-patches |
---|
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 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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 | Content-Type | Size |
---|---|---|
pg_dump_null_pointer_printf-1.patch | text/x-patch | 1.0 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <neilc(at)samurai(dot)com> |
Cc: | pgsql-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: pg_dump: fix crash on error |
Date: | 2005-07-27 04:46:07 |
Message-ID: | 21781.1122439567@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Neil Conway <neilc(at)samurai(dot)com> writes:
> If pg_dump fails to connect to Postgres, it attempts to print an error
> message in ConnectDatabase():
> ...
> 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).
[ scratches head... ] Did this code change recently? It's a tad hard
to believe that such a thing could have gone unnoticed for long.
regards, tom lane
From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: pg_dump: fix crash on error |
Date: | 2005-07-27 05:01:12 |
Message-ID: | 42E71518.3000904@samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Tom Lane wrote:
> [ scratches head... ] Did this code change recently? It's a tad hard
> to believe that such a thing could have gone unnoticed for long.
Seems the problem was introduced here:
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/bin/pg_dump/pg_backup_db.c.diff?r1=1.58;r2=1.59
(I could just revert the code to using PQdb(), but I don't think there's
a need to mention the database in the error message ourselves --
PQerrorMessage() should include that information if appropriate.)
-Neil
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <neilc(at)samurai(dot)com> |
Cc: | pgsql-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: pg_dump: fix crash on error |
Date: | 2005-07-27 05:07:27 |
Message-ID: | 21979.1122440847@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Neil Conway <neilc(at)samurai(dot)com> writes:
> Tom Lane wrote:
>> [ scratches head... ] Did this code change recently? It's a tad hard
>> to believe that such a thing could have gone unnoticed for long.
> Seems the problem was introduced here:
> http://developer.postgresql.org/cvsweb.cgi/pgsql/src/bin/pg_dump/pg_backup_db.c.diff?r1=1.58;r2=1.59
Oh dear, that makes it my fault :-(
> (I could just revert the code to using PQdb(), but I don't think there's
> a need to mention the database in the error message ourselves --
> PQerrorMessage() should include that information if appropriate.)
I'd go with reverting it to using PQdb, myself. Looks like I got bit by
the perennial mantra: premature optimization is the root of all evil.
regards, tom lane
From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: pg_dump: fix crash on error |
Date: | 2005-07-27 05:16:34 |
Message-ID: | 42E718B2.3060301@samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Tom Lane wrote:
> I'd go with reverting it to using PQdb, myself.
Fair enough; reverted to using PQdb(), and applied to HEAD and
REL8_0_STABLE.
-Neil