Skip to content

Commit dfb1e9b

Browse files
committed
Further pg_dump / ftello improvements
Make ftello error-checking consistent to all calls and remove a bit of ftello-related code which has been #if 0'd out since 2001. Note that we are not concerned with the ftello() call under snprintf() failing as it is just building a string to call exit_horribly() with; printing -1 in such a case is fine.
1 parent 5e8e794 commit dfb1e9b

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,9 +3347,8 @@ checkSeek(FILE *fp)
33473347
#endif
33483348

33493349
/* Check that ftello works on this file */
3350-
errno = 0;
33513350
tpos = ftello(fp);
3352-
if (errno)
3351+
if (tpos < 0)
33533352
return false;
33543353

33553354
/*

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,9 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10681068
*/
10691069
fseeko(tmp, 0, SEEK_END);
10701070
th->fileLen = ftello(tmp);
1071+
if (th->fileLen < 0)
1072+
exit_horribly(modulename, "could not determine seek position in file: %s\n",
1073+
strerror(errno));
10711074
fseeko(tmp, 0, SEEK_SET);
10721075

10731076
/*
@@ -1212,20 +1215,6 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
12121215

12131216
while (!gotBlock)
12141217
{
1215-
#if 0
1216-
if (ftello(ctx->tarFH) != ctx->tarFHpos)
1217-
{
1218-
char buf1[100],
1219-
buf2[100];
1220-
1221-
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ftello(ctx->tarFH));
1222-
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
1223-
exit_horribly(modulename,
1224-
"mismatch in actual vs. predicted file position (%s vs. %s)\n",
1225-
buf1, buf2);
1226-
}
1227-
#endif
1228-
12291218
/* Save the pos for reporting purposes */
12301219
hPos = ctx->tarFHpos;
12311220

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy