mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-02 15:13:14 +02:00
Make server name check a bit more strict
(% characters made sendnumeric generate invalid format strings)
This commit is contained in:
+10
-2
@@ -1087,6 +1087,7 @@ void charsys_check_for_changes(void)
|
||||
int valid_server_name(char *name)
|
||||
{
|
||||
char *p;
|
||||
int has_dot = 0;
|
||||
|
||||
if (!*name)
|
||||
return 0; /* empty name */
|
||||
@@ -1095,10 +1096,17 @@ int valid_server_name(char *name)
|
||||
return 0; /* oversized */
|
||||
|
||||
for (p = name; *p; p++)
|
||||
if ((*p <= ' ') || (*p > '~'))
|
||||
{
|
||||
if (*p == '.')
|
||||
{
|
||||
has_dot = 1;
|
||||
continue;
|
||||
}
|
||||
if ((*p <= '0') || (*p > 'z'))
|
||||
return 0; /* forbidden chars */
|
||||
}
|
||||
|
||||
if (!strchr(name, '.'))
|
||||
if (!has_dot)
|
||||
return 0; /* no dot */
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user