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

Commitf0e2770

Browse files
committed
Fix off-by-one in pg_xlogdump's fuzzy_open_file().
In the unlikely case of stdin (fd 0) being closed, the off-by-onewould lead to pg_xlogdump failing to open files.Spotted by Coverity.Backpatch to 9.3 where pg_xlogdump was introduced.
1 parentd33f36f commitf0e2770

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎contrib/pg_xlogdump/pg_xlogdump.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fuzzy_open_file(const char *directory, const char *fname)
151151
fd=open(fname,O_RDONLY |PG_BINARY,0);
152152
if (fd<0&&errno!=ENOENT)
153153
return-1;
154-
elseif (fd>0)
154+
elseif (fd >=0)
155155
returnfd;
156156

157157
/* XLOGDIR / fname */
@@ -160,7 +160,7 @@ fuzzy_open_file(const char *directory, const char *fname)
160160
fd=open(fpath,O_RDONLY |PG_BINARY,0);
161161
if (fd<0&&errno!=ENOENT)
162162
return-1;
163-
elseif (fd>0)
163+
elseif (fd >=0)
164164
returnfd;
165165

166166
datadir=getenv("PGDATA");
@@ -172,7 +172,7 @@ fuzzy_open_file(const char *directory, const char *fname)
172172
fd=open(fpath,O_RDONLY |PG_BINARY,0);
173173
if (fd<0&&errno!=ENOENT)
174174
return-1;
175-
elseif (fd>0)
175+
elseif (fd >=0)
176176
returnfd;
177177
}
178178
}
@@ -184,7 +184,7 @@ fuzzy_open_file(const char *directory, const char *fname)
184184
fd=open(fpath,O_RDONLY |PG_BINARY,0);
185185
if (fd<0&&errno!=ENOENT)
186186
return-1;
187-
elseif (fd>0)
187+
elseif (fd >=0)
188188
returnfd;
189189

190190
/* directory / XLOGDIR / fname */
@@ -193,7 +193,7 @@ fuzzy_open_file(const char *directory, const char *fname)
193193
fd=open(fpath,O_RDONLY |PG_BINARY,0);
194194
if (fd<0&&errno!=ENOENT)
195195
return-1;
196-
elseif (fd>0)
196+
elseif (fd >=0)
197197
returnfd;
198198
}
199199
return-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp