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

Commit177be9e

Browse files
committed
Fix fuzzy error handling in pg_basebackup when opening gzFile
First, this code did not bother checking for a failure when callingdup(). Then, per zlib, gzerror() returns NULL for a NULL input, whichcan happen if passing down to gzdopen() an invalid file descriptor or ifthere was an allocation failure.No back-patch is done as this would unlikely be a problem in the field.Per Coverity.Reported-by: Tom Lane
1 parent1c7a0b3 commit177be9e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,20 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
10221022
#ifdefHAVE_LIBZ
10231023
if (compresslevel!=0)
10241024
{
1025-
state.ztarfile=gzdopen(dup(fileno(stdout)),"wb");
1025+
intfd=dup(fileno(stdout));
1026+
if (fd<0)
1027+
{
1028+
pg_log_error("could not duplicate stdout: %m");
1029+
exit(1);
1030+
}
1031+
1032+
state.ztarfile=gzdopen(fd,"wb");
1033+
if (state.ztarfile==NULL)
1034+
{
1035+
pg_log_error("could not open output file: %m");
1036+
exit(1);
1037+
}
1038+
10261039
if (gzsetparams(state.ztarfile,compresslevel,
10271040
Z_DEFAULT_STRATEGY)!=Z_OK)
10281041
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp