]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix inconsistent quoting of role names in ACLs. REL_14_STABLE github/REL_14_STABLE
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Jul 2025 22:50:13 +0000 (18:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Jul 2025 22:50:13 +0000 (18:50 -0400)
commitac8cdb2495d580d6ff08aa624e7851453d3cc2da
tree00625f7a42ebd42f5c46bf07a68091e1e6c33208
parent0514616f0e282e8962322fd72c68104ad0c44267
Fix inconsistent quoting of role names in ACLs.

getid() and putid(), which parse and deparse role names within ACL
input/output, applied isalnum() to see if a character within a role
name requires quoting.  They did this even for non-ASCII characters,
which is problematic because the results would depend on encoding,
locale, and perhaps even platform.  So it's possible that putid()
could elect not to quote some string that, later in some other
environment, getid() will decide is not a valid identifier, causing
dump/reload or similar failures.

To fix this in a way that won't risk interoperability problems
with unpatched versions, make getid() treat any non-ASCII as a
legitimate identifier character (hence not requiring quotes),
while making putid() treat any non-ASCII as requiring quoting.
We could remove the resulting excess quoting once we feel that
no unpatched servers remain in the wild, but that'll be years.

A lesser problem is that getid() did the wrong thing with an input
consisting of just two double quotes ("").  That has to represent an
empty string, but getid() read it as a single double quote instead.
The case cannot arise in the normal course of events, since we don't
allow empty-string role names.  But let's fix it while we're here.

Although we've not heard field reports of problems with non-ASCII
role names, there's clearly a hazard there, so back-patch to all
supported versions.

Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3792884.1751492172@sss.pgh.pa.us
Backpatch-through: 13
src/backend/utils/adt/acl.c
src/test/regress/expected/privileges.out
src/test/regress/sql/privileges.sql