| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Prevent construction of invalid "name" values via element assign |
| Date: | 2026-11-09 14:21:48 |
| Message-ID: | E1xQQFo-000000003Fx-0Me1@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Prevent construction of invalid "name" values via element assignment.
Although type "name" is of length NAMEDATALEN, we must not allow the
last byte to become nonzero. Otherwise, operations that treat it as
a C string will read off the end, resulting in crashes or disclosure
of server memory. array_set_element() failed to enforce this.
Another bad outcome of element assignment could be to construct an
invalidly-encoded multibyte character. Check that too while we're
at it.
Ideally we'd extend array_set_element()'s API to pass the array type
OID, but that's infeasible in released branches, and it seems not
worth the trouble even in master given the tiny usage of fixed-length
array types. Instead just test for elmlen == 1 && arraytyplen ==
NAMEDATALEN to decide whether it's a name.
Reported-by: Anthropic OSS program
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Backpatch-through: 14
Security: CVE-2026-116321
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f22d6aba940d93e49b1f296e616150e357a75d79
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Modified Files
--------------
src/backend/utils/adt/arrayfuncs.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:21:49 | pgsql: Reject more unsafe names in extension script substitutions. |
| Previous Message | Noah Misch | 2026-11-09 14:21:47 | pgsql: pg_basebackup: Fix use of externally-controlled format string |