diff options
author | Noah Misch <noah@leadboat.com> | 2016-08-08 10:07:46 -0400 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2016-08-08 10:07:51 -0400 |
commit | aed0387958e5774b60618b3cca52c6dad871cdba (patch) | |
tree | 843b6ec7fcb5deeaf9c328317efaf02b3428a88a /src/bin/scripts/createlang.c | |
parent | afabfcc0eb16d64bedeaf8152ef748f99edba55d (diff) |
Field conninfo strings throughout src/bin/scripts.
These programs nominally accepted conninfo strings, but they would
proceed to use the original dbname parameter as though it were an
unadorned database name. This caused "reindexdb dbname=foo" to issue an
SQL command that always failed, and other programs printed a conninfo
string in error messages that purported to print a database name. Fix
both problems by using PQdb() to retrieve actual database names.
Continue to print the full conninfo string when reporting a connection
failure. It is informative there, and if the database name is the sole
problem, the server-side error message will include the name. Beyond
those user-visible fixes, this allows a subsequent commit to synthesize
and use conninfo strings without that implementation detail leaking into
messages. As a side effect, the "vacuuming database" message now
appears after, not before, the connection attempt. Back-patch to 9.1
(all supported versions).
Reviewed by Michael Paquier and Peter Eisentraut.
Security: CVE-2016-5424
Diffstat (limited to 'src/bin/scripts/createlang.c')
-rw-r--r-- | src/bin/scripts/createlang.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c index 9bbd67de7bd..9a7adfa72c6 100644 --- a/src/bin/scripts/createlang.c +++ b/src/bin/scripts/createlang.c @@ -192,10 +192,10 @@ main(int argc, char *argv[]) result = executeQuery(conn, sql.data, progname, echo); if (PQntuples(result) > 0) { - PQfinish(conn); fprintf(stderr, _("%s: language \"%s\" is already installed in database \"%s\"\n"), - progname, langname, dbname); + progname, langname, PQdb(conn)); + PQfinish(conn); /* separate exit status for "already installed" */ exit(2); } |