1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +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:30:53 +00:00
parent 103376e075
commit 88c59aeed8

View File

@ -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)