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

Commit2ea9595

Browse files
committed
Add error handling for failing fstat() calls in copy.c.
These calls are pretty much guaranteed not to fail unless somethinghas gone horribly wrong, and even in that case we'd just error out ashort time later. But since several code checkers complain about themissing check it seems worthwile to fix it nonetheless.Pointed out by Coverity.
1 parent8cadeb7 commit2ea9595

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/backend/commands/copy.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,9 @@ BeginCopyTo(Relation rel,
17071707
errmsg("could not open file \"%s\" for writing: %m",
17081708
cstate->filename)));
17091709

1710-
fstat(fileno(cstate->copy_file),&st);
1710+
if (fstat(fileno(cstate->copy_file),&st))
1711+
elog(ERROR,"could not stat file \"%s\": %m",cstate->filename);
1712+
17111713
if (S_ISDIR(st.st_mode))
17121714
ereport(ERROR,
17131715
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -2718,7 +2720,9 @@ BeginCopyFrom(Relation rel,
27182720
errmsg("could not open file \"%s\" for reading: %m",
27192721
cstate->filename)));
27202722

2721-
fstat(fileno(cstate->copy_file),&st);
2723+
if (fstat(fileno(cstate->copy_file),&st))
2724+
elog(ERROR,"could not stat file \"%s\": %m",cstate->filename);
2725+
27222726
if (S_ISDIR(st.st_mode))
27232727
ereport(ERROR,
27242728
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp