]> git.pond.sub.org Git - empserver/commitdiff
Fix navigate/march crash on funny path arguments
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 16 Jan 2010 16:15:22 +0000 (17:15 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 19 Jan 2010 07:40:42 +0000 (08:40 +0100)
For an argument consisting of a valid path plus whitespace,
do_unit_move() eventually passed the whitespace suffix to parse(),
then dereferenced player->argp[0].  But that was null.

Broken in commit 0c12d837, v4.3.7.  Trivial for players to trigger.

src/lib/commands/navi.c

index cf297411e527e02cdfc12cc22fbc120369f289dc..0f6189cdb3124241708d4b2c353e0ba88ecc0c65 100644 (file)
@@ -184,7 +184,10 @@ do_unit_move(struct emp_qelem *ulist, int *together,
            continue;
        }
        ac = parse(cp, scanspace, player->argp, NULL, NULL, NULL);
-       if (ac <= 1) {
+       if (ac <= 0) {
+           player->argp[0] = "";
+           cp = NULL;
+       } else if (ac == 1) {
            sprintf(dp, "%d", leader->uid);
            player->argp[1] = dp;
            cp++;