From 97376fa20f8524cb2f33d51e6a6cf4b04586f7f0 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 3 Feb 2007 12:08:54 +0000 Subject: [PATCH] made CL_SetInfo check for more forbidden characters (key now refuses any form of whitespace, value now refuses \r and \n) and refactored the checking code to make it a bit cleaner git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6781 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cl_main.c b/cl_main.c index 3086515d..d9c70094 100644 --- a/cl_main.c +++ b/cl_main.c @@ -193,7 +193,19 @@ void CL_ClearState(void) void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet) { - if (strchr(key, '\"') || strchr(value, '\"') || (!allowstarkey && key[0] == '*') || (!allowmodel && (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel")))) + int i; + qboolean fail = false; + if (!allowstarkey && key[0] == '*') + fail = true; + if (!allowmodel && (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel"))) + fail = true; + for (i = 0;key[i];i++) + if (key[i] <= ' ' || key[i] == '\"') + fail = true; + for (i = 0;value[i];i++) + if (value[i] == '\r' || value[i] == '\n' || value[i] == '\"') + fail = true; + if (fail) { if (!quiet) Con_Printf("Can't setinfo \"%s\" \"%s\"\n", key, value); -- 2.39.2