From 2da8c4cff39328897aa716a0ba57bdada5aeaf6e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 21 Sep 2022 09:34:22 -0400 Subject: Tighten pg_get_object_address argument checking For publication schemas (OBJECT_PUBLICATION_NAMESPACE) and user mappings (OBJECT_USER_MAPPING), pg_get_object_address() checked the array length of the second argument, but not of the first argument. If the first argument was too long, it would just silently ignore everything but the first argument. Fix that by checking the length of the first argument as well. Reviewed-by: Amit Kapila Discussion: https://www.postgresql.org/message-id/flat/caaef70b-a874-1088-92ef-5ac38269c33b%40enterprisedb.com --- src/backend/catalog/objectaddress.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/backend') diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 798c1a2d1e0..284ca55469e 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2254,10 +2254,16 @@ pg_get_object_address(PG_FUNCTION_ARGS) */ switch (type) { + case OBJECT_PUBLICATION_NAMESPACE: + case OBJECT_USER_MAPPING: + if (list_length(name) != 1) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("name list length must be exactly %d", 1))); + /* fall through to check args length */ + /* FALLTHROUGH */ case OBJECT_DOMCONSTRAINT: case OBJECT_CAST: - case OBJECT_USER_MAPPING: - case OBJECT_PUBLICATION_NAMESPACE: case OBJECT_PUBLICATION_REL: case OBJECT_DEFACL: case OBJECT_TRANSFORM: -- cgit v1.2.3