Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9ad8a2

Browse files
committed
Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
1 parent5185cc8 commitf9ad8a2

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.108 2005/04/30 08:08:51 neilc Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.109 2005/05/17 17:30:29 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -891,24 +891,21 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
891891
if (!fh)
892892
die_horribly(AH,modulename,"could not open TOC file\n");
893893

894-
while (fgets(buf,1024,fh)!=NULL)
894+
while (fgets(buf,sizeof(buf),fh)!=NULL)
895895
{
896-
/*Find acomment */
896+
/*Truncate line atcomment, if any */
897897
cmnt=strchr(buf,';');
898-
if (cmnt==buf)
899-
continue;
900-
901-
/* End string at comment */
902898
if (cmnt!=NULL)
903899
cmnt[0]='\0';
904900

905-
/*Skip if allspaces */
906-
if (strspn(buf," \t")==strlen(buf))
901+
/*Ignore if allblank */
902+
if (strspn(buf," \t\r")==strlen(buf))
907903
continue;
908904

909-
/* Get an ID */
905+
/* Get an ID, check it's valid and not already seen */
910906
id=strtol(buf,&endptr,10);
911-
if (endptr==buf||id <=0||id>AH->maxDumpId)
907+
if (endptr==buf||id <=0||id>AH->maxDumpId||
908+
ropt->idWanted[id-1])
912909
{
913910
write_msg(modulename,"WARNING: line ignored: %s\n",buf);
914911
continue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp