From 26721aa9d1913a76c39bf8f2b964eca0c707c742 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 3 Nov 2007 08:20:54 +0000 Subject: [PATCH] (pln_airbase_ok): Plug information leak: carrier owner was checked last, so when it was (no longer) allied, attempting to fly off it let you test the conditions checked before that. Check owner first. (mission_pln_airbase_ok): Matching change, to avoid diverging from pln_airbase_ok(). --- src/lib/subs/mission.c | 21 +++++++++------------ src/lib/subs/plnsub.c | 15 ++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index c67c34d5..148fb5ff 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -919,12 +919,12 @@ mission_pln_airbase_ok(struct plnstr *pp) || !could_be_on_ship(pp, &ship))) return 0; - /* Can't fly off of inefficient or non-owned, non-allied ships */ - if ((ship.shp_effic < SHP_AIROPS_EFF) || - ((ship.shp_own != pp->pln_own) && - (getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED))) { + if (ship.shp_own != pp->pln_own + && getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) { return 0; } + if (ship.shp_effic < SHP_AIROPS_EFF) + return 0; } else if (pp->pln_land >= 0) { if (!getland(pp->pln_land, &land)) { @@ -935,15 +935,12 @@ mission_pln_airbase_ok(struct plnstr *pp) || !(pcp->pl_flags & P_E))) return 0; - /* Can't fly off of inefficient or non-owned, non-allied units */ - if ((land.lnd_effic < LND_AIROPS_EFF) || - ((land.lnd_own != pp->pln_own) && - (getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED))) { + if (land.lnd_own != pp->pln_own + && getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) return 0; - } - - /* Can't fly off units in ships or other units */ - if ((land.lnd_ship >= 0) || (land.lnd_land >= 0)) { + if (land.lnd_effic < LND_AIROPS_EFF) + return 0; + if (land.lnd_ship >= 0 || land.lnd_land >= 0) { return 0; } diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index 8d572cdc..327d42b3 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -405,15 +405,14 @@ pln_airbase_ok(struct plnstr *pp, int oneway) || !could_be_on_ship(pp, &ship))) return 0; - if (ship.shp_effic < SHP_AIROPS_EFF) - return 0; - /* Can't fly off non-owned ships or non-allied ship */ if ((ship.shp_own != player->cnum) && (getrel(getnatp(ship.shp_own), player->cnum) != ALLIED)) { pr("(note) An ally does not own the ship %s is on\n", prplane(pp)); return 0; } + if (ship.shp_effic < SHP_AIROPS_EFF) + return 0; } else if (pp->pln_land >= 0) { if (!getland(pp->pln_land, &land)) { @@ -424,18 +423,16 @@ pln_airbase_ok(struct plnstr *pp, int oneway) || !(pcp->pl_flags & P_E))) return 0; - if (land.lnd_effic < LND_AIROPS_EFF) - return 0; - /* Can't fly off units in ships or other units */ - if ((land.lnd_ship >= 0) || (land.lnd_land >= 0)) - return 0; - /* Can't fly off non-owned units or non-allied unit */ if ((land.lnd_own != player->cnum) && (getrel(getnatp(land.lnd_own), player->cnum) != ALLIED)) { pr("(note) An ally does not own the unit %s is on\n", prplane(pp)); return 0; } + if (land.lnd_effic < LND_AIROPS_EFF) + return 0; + if (land.lnd_ship >= 0 || land.lnd_land >= 0) + return 0; } else { if (!getsect(pp->pln_x, pp->pln_y, §)) {