]> git.pond.sub.org Git - empserver/commitdiff
(pln_airbase_ok): Plug information leak: carrier owner was checked
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 3 Nov 2007 08:20:54 +0000 (08:20 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 3 Nov 2007 08:20:54 +0000 (08:20 +0000)
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
src/lib/subs/plnsub.c

index c67c34d576edb91dc38c3b30afa0c0e9eae6e32c..148fb5ff842bba343211da655db3eeac39a02980 100644 (file)
@@ -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;
        }
 
index 8d572cdc250943b600542ff67e461c179b969dc4..327d42b3256102ed0641b3c87089d5365f0f176f 100644 (file)
@@ -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, &sect)) {