Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a69dfe5

Browse files
committed
Don't downcase entries within shared_preload_libraries et al.
load_libraries(), which processes the various xxx_preload_libraries GUCs, was parsing them using SplitIdentifierString() which isn't really appropriate for values that could be path names: it downcases unquoted text, and it doesn't allow embedded whitespace unless quoted. Use SplitDirectoriesString() instead. That also allows us to simplify load_libraries() a bit, since canonicalize_path() is now done for it. While this definitely seems like a bug fix, it has the potential to break configuration settings that accidentally worked before because of the downcasing behavior. Also, there's an easy workaround for the bug, namely to double-quote troublesome text. Hence, no back-patch. QL Zhuo, tweaked a bit by me Discussion: https://postgr.es/m/CAB-oJtxHVDc3H+Km3CjB9mY1VDzuyaVH_ZYSz7iXcRqCtb93Ew@mail.gmail.com
1 parent a2141c4 commit a69dfe5

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,9 @@ SplitIdentifierString(char *rawstring, char separator,
33473347

33483348

33493349
/*
3350-
* SplitDirectoriesString --- parse a string containing directory names
3350+
* SplitDirectoriesString --- parse a string containing file/directory names
3351+
*
3352+
* This works fine on file names too; the function name is historical.
33513353
*
33523354
* This is similar to SplitIdentifierString, except that the parsing
33533355
* rules are meant to handle pathnames instead of identifiers: there is

src/backend/utils/init/miscinit.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,12 +1435,12 @@ load_libraries(const char *libraries, const char *gucname, bool restricted)
14351435
/* Need a modifiable copy of string */
14361436
rawstring = pstrdup(libraries);
14371437

1438-
/* Parse string into list of identifiers */
1439-
if (!SplitIdentifierString(rawstring, ',', &elemlist))
1438+
/* Parse string into list of filename paths */
1439+
if (!SplitDirectoriesString(rawstring, ',', &elemlist))
14401440
{
14411441
/* syntax error in list */
1442+
list_free_deep(elemlist);
14421443
pfree(rawstring);
1443-
list_free(elemlist);
14441444
ereport(LOG,
14451445
(errcode(ERRCODE_SYNTAX_ERROR),
14461446
errmsg("invalid list syntax in parameter \"%s\"",
@@ -1450,28 +1450,25 @@ load_libraries(const char *libraries, const char *gucname, bool restricted)
14501450

14511451
foreach(l, elemlist)
14521452
{
1453-
char *tok = (char *) lfirst(l);
1454-
char *filename;
1453+
/* Note that filename was already canonicalized */
1454+
char *filename = (char *) lfirst(l);
1455+
char *expanded = NULL;
14551456

1456-
filename = pstrdup(tok);
1457-
canonicalize_path(filename);
14581457
/* If restricting, insert $libdir/plugins if not mentioned already */
14591458
if (restricted && first_dir_separator(filename) == NULL)
14601459
{
1461-
char *expanded;
1462-
14631460
expanded = psprintf("$libdir/plugins/%s", filename);
1464-
pfree(filename);
14651461
filename = expanded;
14661462
}
14671463
load_file(filename, restricted);
14681464
ereport(DEBUG1,
14691465
(errmsg("loaded library \"%s\"", filename)));
1470-
pfree(filename);
1466+
if (expanded)
1467+
pfree(expanded);
14711468
}
14721469

1470+
list_free_deep(elemlist);
14731471
pfree(rawstring);
1474-
list_free(elemlist);
14751472
}
14761473

14771474
/*

0 commit comments

Comments
 (0)