aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-04-30 08:19:44 +0000
committerNeil Conway <neilc@samurai.com>2005-04-30 08:19:44 +0000
commit757956ec47589e1c2c97660f90c89ea0e02a13f7 (patch)
tree4dcafb8b4ef816ba6d50801595046806c19adbc4 /src/bin/pg_dump
parent7ce01797bd115b0269ee93bc42fe858a7bfb9a47 (diff)
downloadpostgresql-757956ec47589e1c2c97660f90c89ea0e02a13f7.tar.gz
postgresql-757956ec47589e1c2c97660f90c89ea0e02a13f7.zip
GCC 4.0 includes a new warning option, -Wformat-literal, that emits
a warning when a variable is used as a format string for printf() and similar functions (if the variable is derived from untrusted data, it could include unexpected formatting sequences). This emits too many warnings to be enabled by default, but it does flag a few dubious constructs in the Postgres tree. This patch fixes up the obvious variants: functions that are passed a variable format string but no additional arguments. Most of these are harmless (e.g. the ruleutils stuff), but there is at least one actual bug here: if you create a trigger named "%sfoo", pg_dump will read uninitialized memory and fail to dump the trigger correctly.
Diffstat (limited to 'src/bin/pg_dump')
-rw-r--r--src/bin/pg_dump/dumputils.c4
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c8
-rw-r--r--src/bin/pg_dump/pg_dump.c8
3 files changed, 9 insertions, 11 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index a9ff3482e88..69b7134f320 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.16 2004/12/31 22:03:08 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.16.4.1 2005/04/30 08:19:44 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -160,7 +160,7 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
/* start with $ + dqprefix if not NULL */
appendPQExpBufferChar(delimBuf, '$');
if (dqprefix)
- appendPQExpBuffer(delimBuf, dqprefix);
+ appendPQExpBufferStr(delimBuf, dqprefix);
/*
* Make sure we choose a delimiter which (without the trailing $) is
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index efa810fdf1a..e814a3cc8a1 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.5 2005/04/15 16:40:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.6 2005/04/30 08:19:44 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -345,7 +345,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
* mode with libpq.
*/
if (te->copyStmt && strlen(te->copyStmt) > 0)
- ahprintf(AH, te->copyStmt);
+ ahprintf(AH, "%s", te->copyStmt);
(*AH->PrintTocDataPtr) (AH, te, ropt);
@@ -2197,9 +2197,7 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname)
appendPQExpBuffer(qry, "\\connect %s\n\n",
dbname ? fmtId(dbname) : "-");
-
- ahprintf(AH, qry->data);
-
+ ahprintf(AH, "%s", qry->data);
destroyPQExpBuffer(qry);
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 0f088a7ec1d..33c4fa45f98 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400.4.3 2005/04/15 16:40:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400.4.4 2005/04/30 08:19:44 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -975,7 +975,7 @@ dumpTableData_insert(Archive *fout, void *dcontext)
{
if (field > 0)
appendPQExpBuffer(q, ", ");
- appendPQExpBuffer(q, fmtId(PQfname(res, field)));
+ appendPQExpBufferStr(q, fmtId(PQfname(res, field)));
}
appendPQExpBuffer(q, ") ");
archputs(q->data, fout);
@@ -7439,12 +7439,12 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
if (tginfo->tgisconstraint)
{
appendPQExpBuffer(query, "CREATE CONSTRAINT TRIGGER ");
- appendPQExpBuffer(query, fmtId(tginfo->tgconstrname));
+ appendPQExpBufferStr(query, fmtId(tginfo->tgconstrname));
}
else
{
appendPQExpBuffer(query, "CREATE TRIGGER ");
- appendPQExpBuffer(query, fmtId(tginfo->dobj.name));
+ appendPQExpBufferStr(query, fmtId(tginfo->dobj.name));
}
appendPQExpBuffer(query, "\n ");