From 8bdb5c5c1b5a672a280664b798687adc158fe3f7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 25 Feb 2010 07:07:28 +0100 Subject: [PATCH] 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. --- src/lib/player/empmod.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/player/empmod.c b/src/lib/player/empmod.c index fe75b408f..b9ec9d6a5 100644 --- a/src/lib/player/empmod.c +++ b/src/lib/player/empmod.c @@ -141,7 +141,7 @@ struct cmndstr player_coms[] = { 1, load, C_MOD, NORM + CAP}, {"lookout ", 1, look, 0, NORM + CAP}, {"lost", 0, lost, 0, NORM}, - {"lradar ", 1, lrad, 0, NORM + CAP}, + {"lradar ", 1, lrad, C_MOD, NORM + CAP}, {"lretreat [i|h|b|c]", 1, lretr, C_MOD, NORM + CAP}, {"lstat ", 0, lsta, C_MOD, NORM}, @@ -176,7 +176,7 @@ struct cmndstr player_coms[] = { {"origin ", 1, orig, C_MOD, NORM}, {"paradrop ", 3, para, C_MOD, NORM + MONEY + CAP}, - {"path ", 0, path, 0, NORM}, + {"path ", 0, path, C_MOD, NORM}, {"payoff ", 0, payo, C_MOD, NORM}, {"pbmap [s|l|n|p|r|t|*|h]", 0, map, C_MOD, NORM}, {"pboard ", 3, pboa, C_MOD, NORM + MONEY + CAP}, @@ -192,7 +192,7 @@ struct cmndstr player_coms[] = { {"pstat ", 0, pstat, 0, NORM}, {"qorder ", 0, qorde, C_MOD, NORM + CAP}, {"quit", 0, quit, 0, VIS}, - {"radar ", 1, rada, 0, NORM + CAP}, + {"radar ", 1, rada, C_MOD, NORM + CAP}, {"range ", 1, range, C_MOD, NORM + CAP}, {"read [yes|no|]", 0, rea, C_MOD, VIS}, {"realm []", 0, real, C_MOD, NORM}, @@ -208,17 +208,17 @@ struct cmndstr player_coms[] = { {"resource ", 0, reso, 0, NORM}, {"retreat [i|t|s|h|b|d|u|c]", 1, retr, C_MOD, NORM + CAP}, - {"route ", 1, rout, 0, NORM}, + {"route ", 1, rout, C_MOD, NORM}, {"sabotage ", 1, sabo, C_MOD, NORM + MONEY + CAP}, {"sail ", 1, sail, C_MOD, NORM + CAP}, {"satellite [ [?cond&cond&...]]", - 1, sate, 0, NORM + MONEY + CAP}, + 1, sate, C_MOD, NORM + MONEY + CAP}, {"sbmap [s|l|n|p|r|t|*|h]", 0, map, C_MOD, NORM}, {"scrap ", 2, scra, C_MOD, NORM + MONEY + CAP}, {"scuttle ", 5, scut, C_MOD, NORM + CAP}, {"sdump []", 0, sdump, 0, NORM}, - {"sect ", 0, sct, 0, NORM}, + {"sect ", 0, sct, C_MOD, NORM}, {"sell ", 1, sell, C_MOD, NORM + CAP}, {"set ", 1, set, C_MOD, NORM + CAP}, @@ -245,7 +245,7 @@ struct cmndstr player_coms[] = { {"stop ", 1, stop, C_MOD, NORM + CAP}, {"strength ", 1, stre, C_MOD, NORM}, {"supply ", 1, supp, C_MOD, NORM + CAP}, - {"survey ", 0, surv, 0, NORM + CAP}, + {"survey ", 0, surv, C_MOD, NORM + CAP}, {"swapsector ", 0, swaps, C_MOD, GOD}, {"sweep ", 3, reco, C_MOD, NORM + MONEY + CAP}, -- 2.43.0