Skip to content

Commit 418414d

Browse files
committed
Check for fseeko() failure in pg_dump's _tarAddFile().
Coverity pointed out, not unreasonably, that we checked fseeko's result at every other call site but these. Failure to seek in the temp file (note this is NOT pg_dump's output file) seems quite unlikely, and even if it did happen the file length cross-check further down would probably detect the problem. Still, that's a poor excuse for not checking the result of a system call.
1 parent 65a6769 commit 418414d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,13 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10851085
/*
10861086
* Find file len & go back to start.
10871087
*/
1088-
fseeko(tmp, 0, SEEK_END);
1088+
if (fseeko(tmp, 0, SEEK_END) != 0)
1089+
fatal("error during file seek: %m");
10891090
th->fileLen = ftello(tmp);
10901091
if (th->fileLen < 0)
10911092
fatal("could not determine seek position in archive file: %m");
1092-
fseeko(tmp, 0, SEEK_SET);
1093+
if (fseeko(tmp, 0, SEEK_SET) != 0)
1094+
fatal("error during file seek: %m");
10931095

10941096
_tarWriteHeader(th);
10951097

0 commit comments

Comments
 (0)