Fix read beyond end of conditional argument on missing operand
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 12 May 2013 09:55:42 +0000 (11:55 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 12 May 2013 16:53:29 +0000 (18:53 +0200)
commit809a4e2321ca10cab0e35d9e84dab6a8d125095f
tree0ca02c5d83de456d9c7697dd24f4a71a7327683e
parent59a199c69dba177dccf9035b84b823fad3a3614c
Fix read beyond end of conditional argument on missing operand

nstr_parse_val() interprets argument "" as (empty) identifier, then
returns a pointer right beyond the end of the string.

The argument points into player->argbuf[].  If another argument
follows the conditional, it gets appended to the conditional.  Else,
whatever's left there from previous commands gets appended.  If the
argument is at the very end of player->argbuf[], we parse beyond the
buffer, until we run into a syntax error, or a zero byte.

Since player->argbuf[] is followed by a bunch of pointers, a syntax
error is almost certain.  If we somehow manage to parse all the
pointers and player->lasttime, the runaway parse will end at
player->btused, because that's definitely zero when conditionals get
parsed.
src/lib/subs/nstr.c