Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit6d871a2

Browse 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 parente7889b8 commit6d871a2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎src/backend/tsearch/ts_utils.c

Lines 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
charsharepath[MAXPGPATH];
4040
char*result;
41-
constchar*p;
4241

4342
/*
44-
* Weenforce thatthe basenameis all alpha characters. This may be
45-
* overly restrictive, but we don't want to allow access to anything
43+
* Welimitthe basenameto contain a-z, 0-9, and underscores. This may
44+
*beoverly 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((unsignedchar)*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)

[8]ページ先頭

©2009-2025 Movatter.jp