]> git.pond.sub.org Git - empserver/commitdiff
(nat_ca, cou_ca, ef_init_srv, xdvisible): Plug major information leak:
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 22 May 2006 20:59:11 +0000 (20:59 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 22 May 2006 20:59:11 +0000 (20:59 +0000)
nat_ca[] was designed for visibility to the owner only, while cou_ca[]
was designed for the public.  xdvisible() implemented that for xdump.
But selectors don't care for that!  Since nat_ca[] applies to
EF_NATION, it must be for public visibility.  Broken in 4.2.21.  Fix
by exchanging contents of nat_ca[] and and cou_ca[].  This breaks
clients relying on xdump.

src/lib/commands/xdump.c
src/lib/global/nsc.c
src/lib/subs/fileinit.c

index 09290e83dbff88293f04ecf7dffd9eb20b4932c4..ef9531ae8c465ed48abadadd6294978ff5d82e78 100644 (file)
@@ -215,9 +215,9 @@ xdvisible(int type, void *p)
     case EF_LOST:
        return gp->own != 0 && (gp->own == player->cnum || player->god);
     case EF_NATION:
-       return gp->own == player->cnum;
-    case EF_COUNTRY:
        return ((struct natstr *)p)->nat_stat != STAT_UNUSED;
+    case EF_COUNTRY:
+       return gp->own == player->cnum;
     case EF_NEWS:
        return ((struct nwsstr *)p)->nws_vrb != 0
            && (!opt_HIDDEN || player->god); /* FIXME */
index 6e6a635a6ab8872aafdf2fff9251d87323070658..4a1f8d1b061dd56a419f4ddabddacd10aa207551 100644 (file)
@@ -485,14 +485,14 @@ struct castr trade_ca[] = {
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
-struct castr nat_ca[] = {
+struct castr cou_ca[] = {
     /*
      * This is the owner's view, i.e. it applies only to the own
-     * nation.  The public view cou_ca[], which applies to all
+     * nation.  The public view nat_ca[], which applies to all
      * nations, has the same selectors with different flags: NSC_DEITY
      * is set except for cnum (which must come first) and all
      * NSC_EXTRA selectors, NSC_EXTRA is cleared.
-     * cou_ca[] should also make tech, research, education and
+     * nat_ca[] should also make tech, research, education and
      * happiness available, but we can't express the obfuscation
      * necessary for foreign levels.
      */
@@ -543,7 +543,7 @@ struct castr nat_ca[] = {
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
-struct castr cou_ca[sizeof(nat_ca) / sizeof(*nat_ca)];
+struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
 /* initialized in ef_init_srv() */
 
 struct castr realm_ca[] = {
index f604bf85929c257cf52bead21df94fea660443ce..d62421605aa26b899ef6464397679a678d186ca1 100644 (file)
@@ -71,16 +71,16 @@ ef_init_srv(void)
        empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
     }
 
-    for (i = 0; nat_ca[i].ca_name; i++) {
-       cou_ca[i] = nat_ca[i];
-       flags = cou_ca[i].ca_flags | NSC_CONST;
+    for (i = 0; cou_ca[i].ca_name; i++) {
+       nat_ca[i] = cou_ca[i];
+       flags = nat_ca[i].ca_flags | NSC_CONST;
        if (flags & NSC_EXTRA)
            flags &= ~NSC_EXTRA;
        else if (i != 0)
            flags |= NSC_DEITY;
-       cou_ca[i].ca_flags = flags;
+       nat_ca[i].ca_flags = flags;
     }
-    cou_ca[i] = nat_ca[i];
+    nat_ca[i] = cou_ca[i];
 
     ef_open_srv();
     if (ef_verify() < 0)