]> git.pond.sub.org Git - empserver/commit
Document buffer overrun for long land paths
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 20 Mar 2011 09:06:33 +0000 (10:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 11 Apr 2011 20:29:13 +0000 (22:29 +0200)
commite30dc41717b915c3e6a78384e91c7c4706a27f65
tree39ec13b71f9b6259a8f6b4596af13163366c5fb7
parent5333782046d7cff6654915e9eb545f3a303e6741
Document buffer overrun for long land paths

BestLandPath(), BestDistPath() and best_path() are unsafe by design:
they take a path[] argument without a size, and blindly assume there's
enough space.  When that's wrong, bp_path() overruns the caller's
buffer.

move_ground() and assemble_dist_paths() provide space for 512
characters.  best(), dist(), path(), att_reacting_units(), s_commod()
and do_unit_move() provide space for 1024 characters.

A malicious player can arrange paths longer than that, but it takes a
lot of land.

BestAirPath() and BestShipPath() also take a path[] argument without a
size, but they're actually safe: bestownedpath() writes at most 100
(MAXROUTE) characters, perform_mission_bomb() provides space for 512,
sorde(), getpath(), do_unit_move() and nav_ship() for 1024.
src/lib/common/path.c