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

Commit85738a5

Browse files
committed
Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(),the wrong variable's value was printed, and so the message made no sense.Clean up a couple other coding infelicities while at it.
1 parent10a81b3 commit85738a5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.32.2.3 2007/08/06 01:38:57 tgl Exp $
19+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.32.2.4 2007/08/29 16:32:11 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -1021,15 +1021,16 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10211021
*/
10221022
fseeko(tmp,0,SEEK_END);
10231023
th->fileLen=ftello(tmp);
1024+
fseeko(tmp,0,SEEK_SET);
1025+
10241026
if (th->fileLen>MAX_TAR_MEMBER_FILELEN)
10251027
die_horribly(AH,modulename,"archive member too large for tar format\n");
1026-
fseeko(tmp,0,SEEK_SET);
10271028

10281029
_tarWriteHeader(th);
10291030

1030-
while ((cnt=fread(&buf[0],1,32767,tmp))>0)
1031+
while ((cnt=fread(buf,1,sizeof(buf),tmp))>0)
10311032
{
1032-
res=fwrite(&buf[0],1,cnt,th->tarFH);
1033+
res=fwrite(buf,1,cnt,th->tarFH);
10331034
if (res!=cnt)
10341035
die_horribly(AH,modulename,
10351036
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
@@ -1038,15 +1039,16 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10381039
}
10391040

10401041
if (fclose(tmp)!=0)/* This *should* delete it... */
1041-
die_horribly(AH,modulename,"could not close tar member: %s\n",strerror(errno));
1042+
die_horribly(AH,modulename,"could not close tar member: %s\n",
1043+
strerror(errno));
10421044

10431045
if (len!=th->fileLen)
10441046
{
1045-
charbuf1[100],
1046-
buf2[100];
1047+
charbuf1[32],
1048+
buf2[32];
10471049

1048-
snprintf(buf1,100,INT64_FORMAT, (int64)len);
1049-
snprintf(buf2,100,INT64_FORMAT, (int64)th->pos);
1050+
snprintf(buf1,sizeof(buf1),INT64_FORMAT, (int64)len);
1051+
snprintf(buf2,sizeof(buf2),INT64_FORMAT, (int64)th->fileLen);
10501052
die_horribly(AH,modulename,"actual file length (%s) does not match expected (%s)\n",
10511053
buf1,buf2);
10521054
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp