Skip to content

Commit 1b9cde5

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 1c164ef commit 1b9cde5

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
@@ -1082,11 +1082,13 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10821082
/*
10831083
* Find file len & go back to start.
10841084
*/
1085-
fseeko(tmp, 0, SEEK_END);
1085+
if (fseeko(tmp, 0, SEEK_END) != 0)
1086+
fatal("error during file seek: %m");
10861087
th->fileLen = ftello(tmp);
10871088
if (th->fileLen < 0)
10881089
fatal("could not determine seek position in archive file: %m");
1089-
fseeko(tmp, 0, SEEK_SET);
1090+
if (fseeko(tmp, 0, SEEK_SET) != 0)
1091+
fatal("error during file seek: %m");
10901092

10911093
_tarWriteHeader(th);
10921094

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