From 1ebd79c8805a743efc4c5ad3f8ba596151b1d6e7 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Mon, 28 Mar 2016 17:26:42 +1000 Subject: [PATCH] Update to only allow alpha characters in usernames --- users.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/users.c b/users.c index 0bc5044..ac070cb 100644 --- a/users.c +++ b/users.c @@ -348,6 +348,7 @@ struct user_record *new_user(int socket) { char c; int nameok = 0; int passok = 0; + int i; user = (struct user_record *)malloc(sizeof(struct user_record)); s_putstring(socket, "\r\n\r\n"); @@ -365,11 +366,17 @@ struct user_record *new_user(int socket) { continue; } - if (strchr(buffer, '%') != NULL) { - s_putstring(socket, "Sorry, invalid character.\r\n"); - continue; + for (i=0;i= 97 && tolower(buffer[i]) <= 122)) { + s_putstring(socket, "Sorry, invalid character, can only use alpha characters.\r\n"); + nameok = 1; + break; + } + } + if (nameok == 1) { + nameok = 0; + continue; } - if (strcasecmp(buffer, "unknown") == 0) { s_putstring(socket, "Sorry, that name is reserved.\r\n"); continue;