1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-03 01:21:48 +03:00

Guard against duplicate IDs in input file in SortTocFromFile().

Per report from Brian Hackett.
This commit is contained in:
Tom Lane 2005-05-17 17:31:15 +00:00
parent e5921b3230
commit e3d0bd8d48

View File

@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * 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) if (!fh)
die_horribly(AH, modulename, "could not open TOC file\n"); 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 */ /* Find a comment */
cmnt = strchr(buf, ';'); cmnt = strchr(buf, ';');
@ -987,10 +987,13 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
if (!te) if (!te)
die_horribly(AH, modulename, "could not find entry for id %d\n", id); 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); _moveAfter(AH, tePrev, te);
tePrev = te; tePrev = te;
}
} }
if (fclose(fh) != 0) if (fclose(fh) != 0)