pgsql: Reject empty names and recursion in config-file includedirectiv - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Reject empty names and recursion in config-file includedirectiv
Date
Msg-id E1i2gSV-0004zJ-27@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Reject empty names and recursion in config-file include directives.

An empty file name or subdirectory name leads join_path_components() to
just produce the parent directory name, which leads to weird failures or
recursive inclusions.  Let's throw a specific error for that.  It takes
only slightly more code to detect all-blank names, so do so.

Also, detect direct recursion, ie a file calling itself.  As coded
this will also detect recursion via "include_dir '.'", which is
perhaps more likely than explicitly including the file itself.

Detecting indirect recursion would require API changes for guc-file.l
functions, which seems not worth it since extensions might call them.
The nesting depth limit will catch such cases eventually, just not
with such an on-point error message.

In passing, adjust the example usages in postgresql.conf.sample
to perhaps eliminate the problem at the source: there's no reason
for the examples to suggest that an empty value is valid.

Per a trouble report from Brent Bates.  Back-patch to 9.5; the
issue is old, but the code in 9.4 is enough different that the
patch doesn't apply easily, and it doesn't seem worth the trouble
to fix there.

Ian Barwick and Tom Lane

Discussion: https://postgr.es/m/8c8bcbca-3bd9-dc6e-8986-04a5abdef142@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6e42130568ad28bed857948f5a3192dbf01624dc

Modified Files
--------------
src/backend/utils/misc/guc-file.l             | 58 +++++++++++++++++++++++++++
src/backend/utils/misc/postgresql.conf.sample |  9 +++--
2 files changed, 63 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: Fix error handling of vacuumdb and reindexdb when runningout of
Next
From: Tom Lane
Date:
Subject: pgsql: Add missing newline in help output.