summaryrefslogtreecommitdiff
path: root/src/backend/libpq
diff options
context:
space:
mode:
authorMichael Paquier2022-11-24 22:40:12 +0000
committerMichael Paquier2022-11-24 22:40:12 +0000
commitd13b684117bdf136f97db5bcba2be524ed038b6d (patch)
tree14d0c7d76f0852137a0fb40e23d1456214f59f45 /src/backend/libpq
parent2d1f3bce97a9f4ac3ec4acbf337ffef598522216 (diff)
Introduce variables for initial and max nesting depth on configuration files
The code has been assuming already in a few places that the initial recursion nesting depth is 0, and the recent changes in hba.c (mainly 783e8c6) have relies on this assumption in more places. The maximum recursion nesting level is assumed to be 10 for hba.c and GUCs. Author: Julien Rouhaud Discussion: https://postgr.es/m/20221124090724.n7amf5kpdhx6vb76@jrouhaud
Diffstat (limited to 'src/backend/libpq')
-rw-r--r--src/backend/libpq/hba.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 862ec18e913..95677c48e43 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -79,7 +79,7 @@ typedef struct
/*
* Memory context holding the list of TokenizedAuthLines when parsing
* HBA or ident configuration files. This is created when opening the first
- * file (depth of 0).
+ * file (depth of CONF_FILE_START_DEPTH).
*/
static MemoryContext tokenize_context = NULL;
@@ -620,7 +620,7 @@ free_auth_file(FILE *file, int depth)
FreeFile(file);
/* If this is the last cleanup, remove the tokenization context */
- if (depth == 0)
+ if (depth == CONF_FILE_START_DEPTH)
{
MemoryContextDelete(tokenize_context);
tokenize_context = NULL;
@@ -650,7 +650,7 @@ open_auth_file(const char *filename, int elevel, int depth,
* avoid dumping core due to stack overflow if an include file loops back
* to itself. The maximum nesting depth is pretty arbitrary.
*/
- if (depth > 10)
+ if (depth > CONF_FILE_MAX_DEPTH)
{
ereport(elevel,
(errcode_for_file_access(),
@@ -684,7 +684,7 @@ open_auth_file(const char *filename, int elevel, int depth,
* tokenization. This will be closed with this file when coming back to
* this level of cleanup.
*/
- if (depth == 0)
+ if (depth == CONF_FILE_START_DEPTH)
{
/*
* A context may be present, but assume that it has been eliminated
@@ -762,7 +762,7 @@ tokenize_auth_file(const char *filename, FILE *file, List **tok_lines,
initStringInfo(&buf);
- if (depth == 0)
+ if (depth == CONF_FILE_START_DEPTH)
*tok_lines = NIL;
while (!feof(file) && !ferror(file))