mirror of https://github.com/citusdata/citus.git
Check for absolute paths in COPY with format transmit
parent
cb6b0e820c
commit
306c58d59b
|
@ -635,6 +635,8 @@ IsTransmitStmt(Node *parsetree)
|
||||||
static void
|
static void
|
||||||
VerifyTransmitStmt(CopyStmt *copyStatement)
|
VerifyTransmitStmt(CopyStmt *copyStatement)
|
||||||
{
|
{
|
||||||
|
char *fileName = NULL;
|
||||||
|
|
||||||
/* do some minimal option verification */
|
/* do some minimal option verification */
|
||||||
if (copyStatement->relation == NULL ||
|
if (copyStatement->relation == NULL ||
|
||||||
copyStatement->relation->relname == NULL)
|
copyStatement->relation->relname == NULL)
|
||||||
|
@ -643,6 +645,20 @@ VerifyTransmitStmt(CopyStmt *copyStatement)
|
||||||
errmsg("FORMAT 'transmit' requires a target file")));
|
errmsg("FORMAT 'transmit' requires a target file")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileName = copyStatement->relation->relname;
|
||||||
|
|
||||||
|
if (is_absolute_path(fileName))
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
|
(errmsg("absolute path not allowed"))));
|
||||||
|
}
|
||||||
|
else if (!path_is_relative_and_below_cwd(fileName))
|
||||||
|
{
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
|
(errmsg("path must be in or below the current directory"))));
|
||||||
|
}
|
||||||
|
|
||||||
if (copyStatement->filename != NULL)
|
if (copyStatement->filename != NULL)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
|
Loading…
Reference in New Issue