]> git.pond.sub.org Git - empserver/commitdiff
Fix getpath() not to crash when path exceeds MAX_PATH_LEN
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 14 Jan 2010 21:39:42 +0000 (22:39 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 19 Jan 2010 07:40:17 +0000 (08:40 +0100)
Trivial for players to trigger.  Broken in commit 0b0612ea, v4.3.16.
Spotted by the Clang Static Analyzer.

src/lib/subs/paths.c

index e9754b3db214440ef7208fa2cd1b17fe16ff9230..4a95ed38739e98cdb4e6dfe3609393783e98588a 100644 (file)
@@ -173,7 +173,7 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
     if (p + strlen(bp) + 1 >= buf + MAX_PATH_LEN) {
        pr("Path length may not exceed %d.\n", MAX_PATH_LEN);
        pr("Aborting...\n");
-       bp = NULL;
+       return NULL;
     }
     strcpy(p, bp);
     if (*bp)