Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
This commit is contained in:
parent
5185cc8eae
commit
f9ad8a2802
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.108 2005/04/30 08:08:51 neilc Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.109 2005/05/17 17:30:29 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -891,24 +891,21 @@ 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 */
|
/* Truncate line at comment, if any */
|
||||||
cmnt = strchr(buf, ';');
|
cmnt = strchr(buf, ';');
|
||||||
if (cmnt == buf)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* End string at comment */
|
|
||||||
if (cmnt != NULL)
|
if (cmnt != NULL)
|
||||||
cmnt[0] = '\0';
|
cmnt[0] = '\0';
|
||||||
|
|
||||||
/* Skip if all spaces */
|
/* Ignore if all blank */
|
||||||
if (strspn(buf, " \t") == strlen(buf))
|
if (strspn(buf, " \t\r") == strlen(buf))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Get an ID */
|
/* Get an ID, check it's valid and not already seen */
|
||||||
id = strtol(buf, &endptr, 10);
|
id = strtol(buf, &endptr, 10);
|
||||||
if (endptr == buf || id <= 0 || id > AH->maxDumpId)
|
if (endptr == buf || id <= 0 || id > AH->maxDumpId ||
|
||||||
|
ropt->idWanted[id - 1])
|
||||||
{
|
{
|
||||||
write_msg(modulename, "WARNING: line ignored: %s\n", buf);
|
write_msg(modulename, "WARNING: line ignored: %s\n", buf);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue