From cf2043478213c421f70701038035496a8d74f46f Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 17 May 1994 09:43:47 +0000 Subject: [PATCH] (validate_x_resource_name): Don't let Vx_resource_name have invalid characters. --- src/xfns.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/xfns.c b/src/xfns.c index c0313b20b0..5fc2ac650c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1322,7 +1322,26 @@ x_set_vertical_scroll_bars (f, arg, oldval) static void validate_x_resource_name () { - if (! STRINGP (Vx_resource_name)) + if (STRINGP (Vx_resource_name)) + { + int len = XSTRING (Vx_resource_name)->size; + unsigned char *p = XSTRING (Vx_resource_name)->data; + int i; + + /* Allow only letters, digits, - and _, + because those are all that X allows. */ + for (i = 0; i < len; i++) + { + int c = p[i]; + if (! ((c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || c == '-' || c == '_')) + goto fail; + } + } + else + fail: Vx_resource_name = make_string ("emacs", 5); } -- 2.20.1