mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 06:42:26 +00:00
port Mercury's Userinfo validation over from cougar.
This commit is contained in:
parent
759729b5a8
commit
7a0ba8ca2e
3 changed files with 29 additions and 1 deletions
|
@ -48,5 +48,6 @@ void Info_RemovePrefixedKeys (char *start, char prefix);
|
|||
void Info_SetValueForKey (char *s, char *key, char *value, size_t maxsize);
|
||||
void Info_SetValueForStarKey (char *s, char *key, char *value, size_t maxsize);
|
||||
char *Info_ValueForKey (char *s, char *key);
|
||||
qboolean Info_Validate (char *s);
|
||||
|
||||
#endif // __info_h_
|
||||
|
|
|
@ -327,3 +327,20 @@ Info_Print (char *s)
|
|||
Con_Printf ("%s\n", value);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean
|
||||
Info_Validate (char *s)
|
||||
{
|
||||
int count;
|
||||
char *p;
|
||||
|
||||
if (!s || *s == '\0')
|
||||
return false;
|
||||
|
||||
for (p = s, count = 0; *p != '\0'; p++)
|
||||
if (*p == '\\')
|
||||
count++;
|
||||
|
||||
return (!(count % 2));
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,13 @@ SVC_DirectConnect (void)
|
|||
strncpy (userinfo, Cmd_Argv (4), sizeof (userinfo) - 2);
|
||||
userinfo[sizeof (userinfo) - 2] = 0;
|
||||
|
||||
// Validate the userinfo string.
|
||||
if (!Info_Validate(userinfo)) {
|
||||
Netchan_OutOfBandPrint (net_from, "%c\nInvalid userinfo string.\n",
|
||||
A2C_PRINT);
|
||||
return;
|
||||
}
|
||||
|
||||
// see if the challenge is valid
|
||||
for (i = 0; i < MAX_CHALLENGES; i++) {
|
||||
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr)) {
|
||||
|
@ -1761,7 +1768,10 @@ SV_ExtractFromUserinfo (client_t *cl)
|
|||
|
||||
// if the new name was not set (due to the info string being too long), drop the client to prevent an infinite loop
|
||||
if(strcmp(val, newname)) {
|
||||
SV_ClientPrintf (cl, PRINT_HIGH, "Please choose a different name.\n");
|
||||
Netchan_OutOfBandPrint (net_from,
|
||||
"%c\nPlease choose a different name.\n", A2C_PRINT);
|
||||
SV_ClientPrintf (cl, PRINT_HIGH,
|
||||
"Please choose a different name.\n");
|
||||
Con_Printf("Client %d kicked for invalid name\n", cl->userid);
|
||||
SV_DropClient (cl);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue