copy_from_pathcheck.patch
application/octet-stream
Filename: copy_from_pathcheck.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/commands/copy.c | 8 | 0 |
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);