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

Commitd1c5752

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 parent14570c2 commitd1c5752

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
@@ -171,7 +171,7 @@ fuzzy_open_file(const char *directory, const char *fname)
171171
fd=open(fname,O_RDONLY |PG_BINARY,0);
172172
if (fd<0&&errno!=ENOENT)
173173
return-1;
174-
elseif (fd>0)
174+
elseif (fd >=0)
175175
returnfd;
176176

177177
/* XLOGDIR / fname */
@@ -180,7 +180,7 @@ fuzzy_open_file(const char *directory, const char *fname)
180180
fd=open(fpath,O_RDONLY |PG_BINARY,0);
181181
if (fd<0&&errno!=ENOENT)
182182
return-1;
183-
elseif (fd>0)
183+
elseif (fd >=0)
184184
returnfd;
185185

186186
datadir=getenv("PGDATA");
@@ -192,7 +192,7 @@ fuzzy_open_file(const char *directory, const char *fname)
192192
fd=open(fpath,O_RDONLY |PG_BINARY,0);
193193
if (fd<0&&errno!=ENOENT)
194194
return-1;
195-
elseif (fd>0)
195+
elseif (fd >=0)
196196
returnfd;
197197
}
198198
}
@@ -204,7 +204,7 @@ fuzzy_open_file(const char *directory, const char *fname)
204204
fd=open(fpath,O_RDONLY |PG_BINARY,0);
205205
if (fd<0&&errno!=ENOENT)
206206
return-1;
207-
elseif (fd>0)
207+
elseif (fd >=0)
208208
returnfd;
209209

210210
/* directory / XLOGDIR / fname */
@@ -213,7 +213,7 @@ fuzzy_open_file(const char *directory, const char *fname)
213213
fd=open(fpath,O_RDONLY |PG_BINARY,0);
214214
if (fd<0&&errno!=ENOENT)
215215
return-1;
216-
elseif (fd>0)
216+
elseif (fd >=0)
217217
returnfd;
218218
}
219219
return-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp