Mercurial > irccd
changeset 1026:724ecacb5a17
irccd: fix improper finding of commands
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Feb 2021 10:19:18 +0100 |
parents | 49a126e8aed0 |
children | bab959e4a55a |
files | irccd/peer.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/irccd/peer.c Wed Feb 24 09:38:02 2021 +0100 +++ b/irccd/peer.c Wed Feb 24 10:19:18 2021 +0100 @@ -941,13 +941,18 @@ static int cmp_cmd(const char *key, const struct cmd *cmd) { - return strncmp(key, cmd->name, strlen(cmd->name)); + return strcmp(key, cmd->name); } static const struct cmd * find(const char *line) { - return bsearch(line, cmds, IRC_UTIL_SIZE(cmds), + char cmd[32] = {0}; + + /* Extract the initial part of the line. */ + sscanf(line, "%31s", cmd); + + return bsearch(cmd, cmds, IRC_UTIL_SIZE(cmds), sizeof (cmds[0]), (irc_cmp)cmp_cmd); }