mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 10:31:22 +02:00
Add error handling for failing fstat() calls in copy.c.
These calls are pretty much guaranteed not to fail unless something has gone horribly wrong, and even in that case we'd just error out a short time later. But since several code checkers complain about the missing check it seems worthwile to fix it nonetheless. Pointed out by Coverity.
This commit is contained in:
parent
8cadeb792c
commit
2ea95959af
@ -1707,7 +1707,9 @@ BeginCopyTo(Relation rel,
|
||||
errmsg("could not open file \"%s\" for writing: %m",
|
||||
cstate->filename)));
|
||||
|
||||
fstat(fileno(cstate->copy_file), &st);
|
||||
if (fstat(fileno(cstate->copy_file), &st))
|
||||
elog(ERROR, "could not stat file \"%s\": %m", cstate->filename);
|
||||
|
||||
if (S_ISDIR(st.st_mode))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
@ -2718,7 +2720,9 @@ BeginCopyFrom(Relation rel,
|
||||
errmsg("could not open file \"%s\" for reading: %m",
|
||||
cstate->filename)));
|
||||
|
||||
fstat(fileno(cstate->copy_file), &st);
|
||||
if (fstat(fileno(cstate->copy_file), &st))
|
||||
elog(ERROR, "could not stat file \"%s\": %m", cstate->filename);
|
||||
|
||||
if (S_ISDIR(st.st_mode))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
|
Loading…
Reference in New Issue
Block a user