summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-05-17 17:31:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-05-17 17:31:15 +0000
commite3d0bd8d48a4ba9aa236e6cc901676ad0198ea95 (patch)
treeca6cead804d2063b2264d7a023a62688ce94069f /src
parente5921b3230f175669faf4b97cd967a2dd5023fdc (diff)
Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 4afb011a4cf..474938dece7 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.6 2005/04/30 08:42:17 neilc Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.7 2005/05/17 17:31:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -959,7 +959,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
if (!fh)
die_horribly(AH, modulename, "could not open TOC file\n");
- while (fgets(buf, 1024, fh) != NULL)
+ while (fgets(buf, sizeof(buf), fh) != NULL)
{
/* Find a comment */
cmnt = strchr(buf, ';');
@@ -987,10 +987,13 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
if (!te)
die_horribly(AH, modulename, "could not find entry for id %d\n", id);
- ropt->idWanted[id - 1] = 1;
+ if (!ropt->idWanted[id - 1])
+ {
+ ropt->idWanted[id - 1] = 1;
- _moveAfter(AH, tePrev, te);
- tePrev = te;
+ _moveAfter(AH, tePrev, te);
+ tePrev = te;
+ }
}
if (fclose(fh) != 0)