diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index 932e7ae37b..c1b047b8e9 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -269,20 +269,27 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) /* * Allowing relative paths seems risky * * this also helps us ensure that location is not empty or whitespace */ if (!is_absolute_path(location)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("tablespace location must be an absolute path"))); +#if WIN32 + if (path_contains_parent_reference(location)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("tablespace location cannot contain \"..\""))); +#endif + /* * Check that location isn't too long. Remember that we're going to append * 'PG_XXX//_.'. FYI, we never actually * reference the whole path here, but MakePGDirectory() uses the first two * parts. */ if (strlen(location) + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1 + OIDCHARS > MAXPGPATH) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),