pgsql: pg_dump: Quote not-null constraint names.
pgsql: pg_dump: Quote not-null constraint names.
От:
Noah Misch <noah@leadboat.com>
Дата:
pg_dump: Quote not-null constraint names. When a child table's column is inherited from its parent but the child has its own not-null constraint on it, pg_dump emits that constraint as a standalone table constraint in the child's CREATE TABLE, and it prints the constraint name unquoted. A name needing quotes therefore produces broken SQL (or, for a mixed-case name, a constraint restored under the wrong name), and a name chosen by the table's owner can inject arbitrary commands into the dump, which are then run with the privileges of whoever restores it. To fix, pass the name through fmtId(). Since fmtId() hands back a pointer into a single shared buffer, the constraint name and the column name can't be formatted in one appendPQExpBuffer() call, so the CONSTRAINT clause is printed separately. Reported-by: Anthropic OSS program Reported-by: Sarath Kumar Reported-by: Nikolay Samokhvalov Author: Anthropic OSS program Reviewed-by: Nathan Bossart Reviewed-by: Sami Imseih Security: CVE-2026-116318 Backpatch-through: 18 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/de7a4a3bac0db68963e38d8eee53a73ab0b331f2 Author: Nathan Bossart Modified Files -------------- src/bin/pg_dump/pg_dump.c | 12 +++++------- src/bin/pg_dump/t/002_pg_dump.pl | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-)