Improve bad name sanitisation function

This adds a sanity short circuit, such that if the string passed into
the reject bad name function is 3 times the maximum length allowable for
a name, this function will refuse to process it at all, instead of doing
the character by character processing of the entire name before deciding
it's over maximum length.
This commit is contained in:
oranges
2020-07-05 21:39:12 +00:00
parent 72d0f9f82d
commit 3c0f6bf004
+5 -1
View File
@@ -135,7 +135,11 @@
var/charcount = 0
var/char = ""
// This is a sanity short circuit, if the users name is three times the maximum allowable length of name
// We bail out on trying to process the name at all, as it could be a bug or malicious input and we dont
// Want to iterate all of it.
if(t_len > 3 * MAX_NAME_LEN)
return
for(var/i = 1, i <= t_len, i += length(char))
char = t_in[i]
switch(text2ascii(char))