diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index e8a125b..47ace0e 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -2377,6 +2377,14 @@ BeginCopyFrom(Relation rel, { struct stat st; + /* + * Prevent read from relative path + */ + if (!is_absolute_path(filename)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("relative path not allowed for COPY from file"))); + cstate->filename = pstrdup(filename); cstate->copy_file = AllocateFile(cstate->filename, PG_BINARY_R);