diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-17 17:30:53 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-17 17:30:53 +0000 |
commit | 88c59aeed86d5602d35fbc247573d5a9d9da504c (patch) | |
tree | 0a664fd2e4b40b4672708006b342d4cd51bb7d34 | |
parent | 103376e075cb2c14e1f0ba53fe82de87c654dffc (diff) | |
download | postgresql-88c59aeed86d5602d35fbc247573d5a9d9da504c.tar.gz |
Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 13 |
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 e197624aef..e4f3844eac 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.79.2.4 2005/04/30 08:36:18 neilc Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.79.2.5 2005/05/17 17:30:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -944,7 +944,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, ';'); @@ -972,10 +972,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) |