]> git.pond.sub.org Git - empserver/commitdiff
setsector: Clean up read beyond end of string
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 24 Jan 2013 21:01:45 +0000 (22:01 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:00 +0000 (19:55 +0200)
setsector() reads the first two characters unconditionally.  Wrong if
the first character is NUL.  The second character read isn't actually
used then.  Screwed up in Chainsaw.

When getstarg() returns an empty string, it's always in the buffer
passed as third argument.  Thus, reading the second character is
actually safe.

Clean it up anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/setsect.c

index c1490ab307059c5b20dd7e64baca6064de6298c0..afbff7a49e983e1ee400cd817c5fadb664c97ddf 100644 (file)
@@ -56,7 +56,7 @@ setsector(void)
     what = getstarg(player->argp[1],
                    "Give what (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
                    buf);
     what = getstarg(player->argp[1],
                    "Give what (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
                    buf);
-    if (!what)
+    if (!what || !*what)
        return RET_SYN;
     char0 = what[0];
     char1 = what[1];
        return RET_SYN;
     char0 = what[0];
     char1 = what[1];