]> git.pond.sub.org Git - empserver/commit
Fix unsafe use of shared buffers in commands drawing maps
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 25 Feb 2010 06:07:28 +0000 (07:07 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 10 Mar 2010 08:44:27 +0000 (09:44 +0100)
commit1f2865387a64a294e51e6a83e975488ca7c3a410
tree054ccf86c16debe8d275cab1010cb0c874ae9c1d
parent069fb10409b6dd06495f195e771bccbc1bb58e8e
Fix unsafe use of shared buffers in commands drawing maps

Maps are generally drawn into static scratch buffers.  Each command
has its own buffers.

Static scratch buffers are safe as long as they're never used across
yields.  Player output can yield unless the command has flag C_MOD
set.  Commands lradar, path, radar, route, satellite, sect, survey
hadn't.  If such a command yields while using scratch buffers, another
instance of the command can clobber them.

Abuse seems tricky, but possible: if a malicious player stalls output
just right, a command yields while printing a map from the scratch
buffer.  It resumes only when the malicious player reads some output.
If another player runs the same command before that, it overwrites the
same static scratch buffer with its map.  The malicious player
receives the last such run's map.

4.2.8 fixed the same bug for bmap, lbmap, lmap, map, nmap, pbmap,
pmap, sbmap and smap.

All were broken in 4.2.0.  Except radar maps (lradar and radar) were
already broken in Empire 2 for AIX.
(cherry picked from commit 8bdb5c5c1b5a672a280664b798687adc158fe3f7)
src/lib/player/empmod.c