aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-05-24 11:47:49 +0200
committertomsmeding <tom.smeding@gmail.com>2017-05-24 11:47:49 +0200
commit438254db34608808f7d521fe871e21393542c556 (patch)
tree98f7db24aa2e0d43da154e058572eedc71a26728
parent24e9d1ea30092f2b0ee938b279108e71edcb5239 (diff)
server: Actually check the entire command name
Previously, l(o(g(in?)?)?)? meant "login", since only the cmdlen prefix of the registered command was matched against the sent command. Discovered by surprisedly seeing "list_room" work.
-rw-r--r--command.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/command.c b/command.c
index 01aff9e..1b70369 100644
--- a/command.c
+++ b/command.c
@@ -362,7 +362,8 @@ bool handle_input_line(struct conn_data *data,char *line,size_t linelen){
size_t cmdlen=sepp-line;
size_t cmdi;
for(cmdi=0;cmdi<NCOMMANDS;cmdi++){
- if(strncmp(line,commands[cmdi].cmdname,cmdlen)==0){
+ if(cmdlen==strlen(commands[cmdi].cmdname)&&
+ memcmp(line,commands[cmdi].cmdname,cmdlen)==0){
break;
}
}