From: Markus Armbruster Date: Sat, 16 Jan 2010 15:29:41 +0000 (+0100) Subject: Fix player_login() not to print null pointer X-Git-Tag: v4.3.24~9 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=6c8ba9c3fd4432318984a9e2f873b66dd8dc5166 Fix player_login() not to print null pointer When the input line contains only whitespace, player->argp[0] is null after parse(). This condition was not checked, comtch() returned M_IGNORE, and code handling that printed the null pointer. Some systems (GNU, Windows) deal gracefully with printing null strings, others crash. Trivial to trigger remotely. Before the fix, the value of parse() was assigned, but never used, and that was spotted by the Clang Static Analyzer. --- diff --git a/src/lib/player/login.c b/src/lib/player/login.c index 428f77d1e..7f66a23a0 100644 --- a/src/lib/player/login.c +++ b/src/lib/player/login.c @@ -98,6 +98,10 @@ player_login(void *ud) continue; } ac = parse(buf, space, player->argp, NULL, NULL, NULL); + if (ac <= 0) { + pr_id(player, C_BADCMD, "Can't parse command\n"); + continue; + } cmd = comtch(player->argp[0], login_coms, 0); if (cmd < 0) { pr_id(player, C_BADCMD, "Command %s not found\n", player->argp[0]);