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

Commit835a487

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 parent2d8411a commit835a487

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
@@ -152,7 +152,7 @@ fuzzy_open_file(const char *directory, const char *fname)
152152
fd=open(fname,O_RDONLY |PG_BINARY,0);
153153
if (fd<0&&errno!=ENOENT)
154154
return-1;
155-
elseif (fd>0)
155+
elseif (fd >=0)
156156
returnfd;
157157

158158
/* XLOGDIR / fname */
@@ -161,7 +161,7 @@ fuzzy_open_file(const char *directory, const char *fname)
161161
fd=open(fpath,O_RDONLY |PG_BINARY,0);
162162
if (fd<0&&errno!=ENOENT)
163163
return-1;
164-
elseif (fd>0)
164+
elseif (fd >=0)
165165
returnfd;
166166

167167
datadir=getenv("PGDATA");
@@ -173,7 +173,7 @@ fuzzy_open_file(const char *directory, const char *fname)
173173
fd=open(fpath,O_RDONLY |PG_BINARY,0);
174174
if (fd<0&&errno!=ENOENT)
175175
return-1;
176-
elseif (fd>0)
176+
elseif (fd >=0)
177177
returnfd;
178178
}
179179
}
@@ -185,7 +185,7 @@ fuzzy_open_file(const char *directory, const char *fname)
185185
fd=open(fpath,O_RDONLY |PG_BINARY,0);
186186
if (fd<0&&errno!=ENOENT)
187187
return-1;
188-
elseif (fd>0)
188+
elseif (fd >=0)
189189
returnfd;
190190

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp