Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6d871a2

Browse filesBrowse files
committed
Restrict tsearch config file base names to contain a-z, 0-9, and underscore,
instead of the initial policy of whatever isalpha() likes. Per discussion.
1 parent e7889b8 commit 6d871a2
Copy full SHA for 6d871a2

File tree

Expand file treeCollapse file tree

1 file changed

+13
-13
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-13
lines changed

‎src/backend/tsearch/ts_utils.c

Copy file name to clipboardExpand all lines: src/backend/tsearch/ts_utils.c
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/ts_utils.c,v 1.3 2007/08/25 00:03:59 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/ts_utils.c,v 1.4 2007/09/04 02:16:56 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -38,22 +38,22 @@ get_tsearch_config_filename(const char *basename,
3838
{
3939
char sharepath[MAXPGPATH];
4040
char *result;
41-
const char *p;
4241

4342
/*
44-
* We enforce that the basename is all alpha characters. This may be
45-
* overly restrictive, but we don't want to allow access to anything
43+
* We limit the basename to contain a-z, 0-9, and underscores. This may
44+
* be overly restrictive, but we don't want to allow access to anything
4645
* outside the tsearch_data directory, so for instance '/' *must* be
47-
* rejected. This is the same test used for timezonesets names.
46+
* rejected, and on some platforms '\' and ':' are risky as well.
47+
* Allowing uppercase might result in incompatible behavior between
48+
* case-sensitive and case-insensitive filesystems, and non-ASCII
49+
* characters create other interesting risks, so on the whole a tight
50+
* policy seems best.
4851
*/
49-
for (p = basename; *p; p++)
50-
{
51-
if (!isalpha((unsigned char) *p))
52-
ereport(ERROR,
53-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
54-
errmsg("invalid text search configuration file name \"%s\"",
55-
basename)));
56-
}
52+
if (strspn(basename, "abcdefghijklmnopqrstuvwxyz0123456789_") != strlen(basename))
53+
ereport(ERROR,
54+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
55+
errmsg("invalid text search configuration file name \"%s\"",
56+
basename)));
5757

5858
get_share_path(my_exec_path, sharepath);
5959
result = palloc(MAXPGPATH);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.