diff options
| author | Franklin Wei <git@fwei.tk> | 2016-01-13 20:10:05 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2016-01-13 20:11:03 -0500 |
| commit | abe9f416501c5354be3ce292b4220000edf021ab (patch) | |
| tree | ac8b809e18683ea9eefff58c744c6613b8805a0d /src/client.c | |
| parent | cc9c177672edcc65933b15ba91831bf09bbec023 (diff) | |
| download | netcosm-abe9f416501c5354be3ce292b4220000edf021ab.zip netcosm-abe9f416501c5354be3ce292b4220000edf021ab.tar.gz netcosm-abe9f416501c5354be3ce292b4220000edf021ab.tar.bz2 netcosm-abe9f416501c5354be3ce292b4220000edf021ab.tar.xz | |
WIP on master: d274aa8 rewrite everything to use libev
Diffstat (limited to 'src/client.c')
| -rw-r--r-- | src/client.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client.c b/src/client.c index 77072e2..7b4a9cc 100644 --- a/src/client.c +++ b/src/client.c @@ -26,6 +26,8 @@ static room_id current_room = 0; static volatile sig_atomic_t output_locked = 0; +char *current_user = NULL; + void out_raw(const unsigned char *buf, size_t len) { try_again: @@ -374,8 +376,6 @@ auth: int failures = 0; int authlevel; - - char *current_user; struct userdata_t *current_data = NULL; client_change_state(STATE_AUTH); @@ -409,6 +409,7 @@ auth: { client_change_state(STATE_FAILED); free(current_user); + current_user = NULL; out("Access Denied.\n\n"); if(++failures >= MAX_FAILURES) return; @@ -550,12 +551,18 @@ auth: /* weird pointer voodoo */ /* TODO: simplify */ char pidbuf[MAX(sizeof(pid_t), MSG_MAX)]; - pid_t pid = strtol(pid_s, NULL, 0); + char *end; + pid_t pid = strtol(pid_s, &end, 0); if(pid == getpid()) { out("You cannot kick yourself. Use EXIT instead.\n"); goto next_cmd; } + else if(*end != '\0') + { + out("Expected a child PID after KICK.\n"); + goto next_cmd; + } memcpy(pidbuf, &pid, sizeof(pid)); int len = sizeof(pid_t) + snprintf(pidbuf + sizeof(pid_t), sizeof(pidbuf) - sizeof(pid_t), @@ -624,4 +631,5 @@ auth: done: free(current_user); + current_user = NULL; } |