1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 19:33:27 +01:00

don't allow empty nicks

This commit is contained in:
Jfreegman 2013-11-27 19:34:15 -05:00
parent 9c6662163b
commit 663818156b

View File

@ -219,7 +219,7 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
{ {
/* check arguments */ /* check arguments */
if (argc < 1) { if (argc < 1) {
wprintw(window, "Invalid syntax.\n"); wprintw(window, "Invalid name.\n");
return; return;
} }
@ -232,6 +232,11 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
nick[len] = L'\0'; nick[len] = L'\0';
} }
if(!len) {
wprintw(window, "Invalid name.\n");
return;
}
if (len > TOXIC_MAX_NAME_LENGTH) { if (len > TOXIC_MAX_NAME_LENGTH) {
nick[TOXIC_MAX_NAME_LENGTH] = L'\0'; nick[TOXIC_MAX_NAME_LENGTH] = L'\0';
len = TOXIC_MAX_NAME_LENGTH; len = TOXIC_MAX_NAME_LENGTH;