mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
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. This patch fixes a bug in pg_dump (triggers with formatting sequences in their names are not dumped correctly) and some related pg_dump code that looks dubious; cleanups for more harmless instances have been applied to more recent branches. This patch also fixes an additional format string bug that is present in 7.2 but not in later releases: pg_dump would also fail to correctly dump indexes with formatting sequences in their names.
This commit is contained in:
parent
6dce59ced9
commit
a4c3f7dd19
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.42 2002/02/11 00:18:20 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.42.2.1 2005/04/30 09:08:14 neilc Exp $
|
||||
*
|
||||
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
|
||||
*
|
||||
@ -391,7 +391,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);
|
||||
|
||||
@ -2006,7 +2006,7 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user)
|
||||
appendPQExpBuffer(qry, " %s\n\n",
|
||||
fmtId(user, false));
|
||||
|
||||
ahprintf(AH, qry->data);
|
||||
ahprintf(AH, "%s", qry->data);
|
||||
|
||||
destroyPQExpBuffer(qry);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.241.2.3 2004/03/20 18:12:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.241.2.4 2005/04/30 09:08:14 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -436,7 +436,7 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
|
||||
{
|
||||
if (field > 0)
|
||||
appendPQExpBuffer(q, ",");
|
||||
appendPQExpBuffer(q, fmtId(PQfname(res, field), force_quotes));
|
||||
appendPQExpBufferStr(q, fmtId(PQfname(res, field), force_quotes));
|
||||
}
|
||||
appendPQExpBuffer(q, ") ");
|
||||
archprintf(fout, "%s", q->data);
|
||||
@ -2599,12 +2599,12 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
|
||||
if (tgisconstraint)
|
||||
{
|
||||
appendPQExpBuffer(query, "CREATE CONSTRAINT TRIGGER ");
|
||||
appendPQExpBuffer(query, fmtId(PQgetvalue(res2, i2, i_tgconstrname), force_quotes));
|
||||
appendPQExpBufferStr(query, fmtId(PQgetvalue(res2, i2, i_tgconstrname), force_quotes));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBuffer(query, "CREATE TRIGGER ");
|
||||
appendPQExpBuffer(query, fmtId(tgname, force_quotes));
|
||||
appendPQExpBufferStr(query, fmtId(tgname, force_quotes));
|
||||
}
|
||||
appendPQExpBufferChar(query, ' ');
|
||||
/* Trigger type */
|
||||
@ -4483,7 +4483,7 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
|
||||
}
|
||||
|
||||
resetPQExpBuffer(id1);
|
||||
appendPQExpBuffer(id1, fmtId(indinfo[i].indexrelname, force_quotes));
|
||||
appendPQExpBufferStr(id1, fmtId(indinfo[i].indexrelname, force_quotes));
|
||||
|
||||
resetPQExpBuffer(q);
|
||||
appendPQExpBuffer(q, "%s;\n", indinfo[i].indexdef);
|
||||
|
Loading…
Reference in New Issue
Block a user