]> git.pond.sub.org Git - empserver/commit
Fix crash bug in satellite maps
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 13 May 2008 06:36:06 +0000 (08:36 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 13 May 2008 06:36:06 +0000 (08:36 +0200)
commit0cc474bd6dd095235330f4e15141c9d5e5adc4b4
tree595dab312498b0d2912d0b3c1c10e99271e14e3b
parent7680acc39fd63684c6854f27e99a2a5e18712473
Fix crash bug in satellite maps

The value of diffx() had the wrong sign when the arguments differed by
WORLD_X / 2.  Same for diffy() and WORLD_Y / 2.  satmap() used them to
find the vector from map center to ship or land unit to put on the
map, and got incorrect values for ships and land units directly
opposite to the center in x or y.  The bug made satmap() read a
pointer out bounds of its malloced radbuf[], and then write through
that with unpredictable consequences.

Broken in 4.2.12.  The original bug was in Empire 1.1: it
miscalculated where to put ships on the map (no crash).  An incomplete
fix for radmap() and satmap() appeared in Chainsaw 2 (still no crash).
radmap() got fixed correctly in Chainsaw 3, but satmap() was
forgotten.  That one got "fixed" in 4.2.7, and again in 4.2.12, but
both "fixes" were flawed and could crash.

Fix by backing out the flawed fixes and adopting the fix from radmap()
instead.
include/prototypes.h
src/lib/common/mapdist.c
src/lib/subs/satmap.c