Re: pg_dump fails to dump database - Mailing list pgsql-bugs

From Tom Lane
Subject Re: pg_dump fails to dump database
Date
Msg-id 20957.977074583@sss.pgh.pa.us
Whole thread Raw
In response to pg_dump fails to dump database  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.org writes:
> pg_dump in postgreSQL 7.0.3 fails to dump database. Problem is
> becomeUser procedure in which lastusername stores pointer to name of
> username which is currently connected. becomeUser is called for the
> first time in dumpSchema, which allocated memory, calls becomeUser and
> then frees memory. Then becomeUser is called again during dumping of
> table data, but lastusername points to deallocated memory, so it
> receives SIGSEGV (in strcmp).

Hm.  This is clearly erroneous code, but the odds of a coredump seem
*extremely* remote --- as borne out by the fact that this bug has been
in there for a good long while, and hasn't been noticed before.
strcmp as such isn't going to care whether the string it's pointed
at has been freed and/or overwritten.  It could only coredump if it
scanned past the end of physically allocated memory before hitting a
null, and that seems pretty unlikely, especially given that the other
input string is likely to be short.  What sort of platform are you
running on?

Philip, I see that becomeUser is toast in current sources, but it
seems like _reconnectAsUser might still have the same logic flaw;
wouldn't it be a good idea to make it strdup the value it saves in
currUser?

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: pg_dump fails to dump database
Next
From: Tom Lane
Date:
Subject: Re: Table name scope (was Re: Outer joins aren't working with views)