]> git.pond.sub.org Git - empserver/commitdiff
retreat: Fix stack smash in land unit group retreat
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 20 Jan 2014 19:28:17 +0000 (20:28 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 16 Feb 2014 12:19:25 +0000 (13:19 +0100)
retreat_land() reads ships instead of land units, overrunning local
variable land.  On lucky systems such as mine, this clobbers ni, and
triggers an oops.  On unlucky systems, it crashes.  On really unlucky
systems, it corrupts the land units file.

Broken since land unit retreat was added in Chainsaw 3.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/subs/retreat.c
tests/retreat/01-retreat-1
tests/retreat/final.xdump
tests/retreat/journal.log
tests/retreat/server.log

index 646bb9745815a0dde06cf03c7294e6a2bd97ca4c..6310c43373a02c3eee85aee310adddf6ce5ed56f 100644 (file)
@@ -355,7 +355,7 @@ retreat_land(struct lndstr *lp, char code)
     struct lndstr land;
 
     if (lp->lnd_rflags & RET_GROUP) {
-       snxtitem_group(&ni, EF_SHIP, lp->lnd_army);
+       snxtitem_group(&ni, EF_LAND, lp->lnd_army);
        while (nxtitem(&ni, &land))
            if (land.lnd_own == lp->lnd_own) {
                if (land.lnd_uid == lp->lnd_uid) {
index a1d71495b3a6c5736407ae93167cb84c5643910e..cfda8bf87b1f7d775e023c15489266a6423633d9 100644 (file)
@@ -168,7 +168,7 @@ __cmd added -1 0 0
 bomb 30 . p -2,2 ujh
 l
 44
-| BUG: oopses!
+| BUG: sweeps silently
 || land units retreating fully
 | jh
 bomb 30 . p -2,2 ujh
index 38ea478c4fdf63b4e5179068aa9a5c954f917ced..62e9804f84fdda4bedc2106e0a9fdea10d659fa7 100644 (file)
@@ -1,6 +1,6 @@
 config sect
 owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist ydist avail elev work coastal newdes min gold fert ocontent uran oldown civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad c_dist m_dist s_dist g_dist p_dist i_dist d_dist b_dist f_dist o_dist l_dist h_dist u_dist r_dist c_del m_del s_del g_del p_del i_del d_del b_del f_del o_del l_del h_del u_del r_del mines pstage ptime che che_target fallout access road rail dfense
-2 0 0 15 88 112 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 1 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 healthy 0 0 0 0 0 0 0 0
+2 0 0 15 88 112 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 1 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 91 healthy 0 0 0 0 0 0 0 0
 2 2 0 1 100 127 0 0 0 0 0 0 0 2 0 0 0 0 0 1 0 0 0 0 0 2 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 2 4 0 15 100 127 0 0 0 0 0 0 0 4 0 0 0 0 1 15 0 0 0 0 0 2 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 0 6 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
@@ -362,7 +362,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 6 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 7 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 8 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-9 2 1 1 7 93 120 0 50 0 0 none 0 "" -1 127 42 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+9 2 1 1 7 93 119 0 50 0 0 none 0 "" -1 127 42 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 10 2 4 0 0 61 45 0 50 0 0 none 0 "" -1 127 42 () "" 0 6 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 11 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 12 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
@@ -396,8 +396,8 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 40 2 2 2 0 89 -15 0 50 1 1 none 3 "" -1 127 42 (bombed) "u" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 41 2 3 1 0 86 99 0 50 1 1 none 3 "" -1 127 42 () "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 42 2 1 1 0 83 105 0 50 1 1 none 3 "" -1 127 42 () "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-43 2 1 1 15 100 127 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "yu" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-44 2 1 1 15 93 119 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "yu" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+43 2 0 0 15 97 111 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "u" 0 10 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+44 2 0 0 15 89 102 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "u" 0 10 2 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 45 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 46 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 47 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
@@ -469,6 +469,7 @@ actor action victim times duration time
 2 13 0 3 0 0
 1 19 2 1 0 0
 1 55 2 13 0 0
+2 56 0 2 0 0
 1 55 1 1 0 0
 /config
 config trade
index be0a904129bedf157556de28c0303340d7d4d5c3..be5e7278bf3f0f603e9d89c523860e1bdb6a5102 100644 (file)
     Play#1 output Play#1 1 (# 33)          2    completely  cav  cavalry #33
     Play#1 output Play#1 1 (# 35)          2    completely  cav  cavalry #35
     Play#1 output Play#1 1 (# 42)          2    completely  cav  cavalry #42
-    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
-    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 4 Bomb what? (ship, plane, land unit, efficiency, commodities)
     Play#1 input l
     Play#1 output Play#1 1  #          owner           eff       type
     Play#1 output Play#1 1 (# 33)          2    completely  cav  cavalry #33
     Play#1 output Play#1 1 (# 35)          2    completely  cav  cavalry #35
     Play#1 output Play#1 1 (# 42)          2    completely  cav  cavalry #42
-    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
-    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 4 ac   AH-64 Apache #30, 1 bombs.  Target ('~' to skip)?
     Play#1 input 10
     Play#1 output Play#1 1 72% hitchance...Blam
     Play#1 output Play#1 1 flying over agribusiness at 0,0
     Play#1 output Play#1 1 Target sector is a completely constructed agribusiness
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 60)          2    completely  cav  cavalry #60
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 output Play#1 4 Bomb what? (ship, plane, land unit, efficiency, commodities)
     Play#1 input l
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 60)          2    completely  cav  cavalry #60
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 input 60
     Play#1 output Play#1 1 50% hitchance...Blam-BLAM
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 output Play#1 1 (# 63)          2    completely  cav  cavalry #63
     Play#1 input 61
     Play#1 output Play#1 1 50% hitchance...thud
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 output Play#1 1 (# 63)          2    completely  cav  cavalry #63
     Play#1 input 62
     Play#1 output Play#1 1 50% hitchance...thud
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 output Play#1 1 (# 63)          2    completely  cav  cavalry #63
     Play#1 input 63
     Play#1 output Play#1 1 50% hitchance...thud
     Play#1 output Play#1 1  #          owner           eff       type
+    Play#1 output Play#1 1 (# 43)          2    completely  eng  engineer #43
+    Play#1 output Play#1 1 (# 44)          2    completely  eng  engineer #44
     Play#1 output Play#1 1 (# 61)          2    completely  cav  cavalry #61
     Play#1 output Play#1 1 (# 62)          2    completely  cav  cavalry #62
     Play#1 output Play#1 1 (# 63)          2    completely  cav  cavalry #63
     Play#0 output Play#0 1 Flak! Firing flak guns from unit eng  engineer #44 (aa rating 1)
     Play#0 output Play#0 1 1 pinpoint bombing raid did 28 damage to eng  engineer #44
     Play#0 output Play#0 1     eng  engineer #44 takes 7
+    Play#0 output Play#0 1 eng  engineer #43 retreated with a bombed friend,
+    Play#0 output Play#0 1 and hit a mine in 0,0 while retreating!
+    Play#0 output Play#0 1     eng  engineer #43 takes 3
+    Play#0 output Play#0 1 eng  engineer #44 was bombed,
+    Play#0 output Play#0 1 and hit a mine in 0,0 while retreating!
+    Play#0 output Play#0 1     eng  engineer #44 takes 4
     Play#0 output Play#0 1 1,1 takes 3% collateral damage
     Play#0 output Play#0 1     tra  train #9 takes 1
     Play#0 output Play#0 1 1 planes spotted over 1,1
     Play#0 command land
     Play#0 output Play#0 1 own    # unit type          x,y    a   eff mil frt  mu  fd tch retr xl ln carry
     Play#0 output Play#0 1   1    2 inf  infantry     -3,-1       89%   9 127  85   0  50  42%  0  0
-    Play#0 output Play#0 1   2    9 tra  train         1,1        93%  10 127 120   0  50  42%  0  1
+    Play#0 output Play#0 1   2    9 tra  train         1,1        93%  10 127 119   0  50  42%  0  1
     Play#0 output Play#0 1   2   10 cav  cavalry       4,0        61%   6 127  45   0  50  42%  0  0
     Play#0 output Play#0 1   2   31 cav  cavalry       0,2        99%  10 127 126   0  50  42%  0  0   35S
     Play#0 output Play#0 1   2   32 cav  cavalry       3,1        83%   0 127  96   0  50  42%  0  0
     Play#0 output Play#0 1   2   40 cav  cavalry       2,2        89%   9 127 -15   0  50  42%  0  0
     Play#0 output Play#0 1   2   41 cav  cavalry       3,1        86%   9 127  99   0  50  42%  0  0
     Play#0 output Play#0 1   2   42 cav  cavalry       1,1        83%   9 127 105   0  50  42%  0  0
-    Play#0 output Play#0 1   2   43 eng  engineer      1,1    m  100%  10 127 127   0 130  42%  0  0
-    Play#0 output Play#0 1   2   44 eng  engineer      1,1    m   93%  10 127 119   0 130  42%  0  0
+    Play#0 output Play#0 1   2   43 eng  engineer      0,0    m   97%  10 127 111   0 130  42%  0  0
+    Play#0 output Play#0 1   2   44 eng  engineer      0,0    m   89%  10 127 102   0 130  42%  0  0
     Play#0 output Play#0 1   2   60 cav  cavalry       3,1        73%   7 127  71   0  50  42%  0  0
     Play#0 output Play#0 1   2   61 cav  cavalry       0,0       100%  10 127 127   0  50  42%  0  0
     Play#0 output Play#0 1   2   62 cav  cavalry       0,0       100%  10 127 127   0  50  42%  0  0
     Play#0 output Play#0 1   2   40 cav  cavalry        2,2      u                   b
     Play#0 output Play#0 1   2   41 cav  cavalry        3,1
     Play#0 output Play#0 1   2   42 cav  cavalry        1,1
-    Play#0 output Play#0 1   2   43 eng  engineer       1,1    m yu         Yes      b
-    Play#0 output Play#0 1   2   44 eng  engineer       1,1    m yu         Yes      b
+    Play#0 output Play#0 1   2   43 eng  engineer       0,0    m u          Yes      b
+    Play#0 output Play#0 1   2   44 eng  engineer       0,0    m u          Yes      b
     Play#0 output Play#0 1   2   60 cav  cavalry        3,1
     Play#0 output Play#0 1   2   61 cav  cavalry        0,0      nj                  ihb
     Play#0 output Play#0 1   2   62 cav  cavalry        0,0      nj                  ihb
index f0eb6970f74e693bc5e0caae71b2ae08f7b0bfc4..1a978003d61e381b1669d0a8b1239edb047ff24d 100644 (file)
@@ -8,8 +8,6 @@ Connect from 127.0.0.1
 Connect from 127.0.0.1
 tester@127.0.0.1 using country #1
 tester@127.0.0.1 logged in as country #1
-Oops: bug in ../src/lib/subs/nxtitem.c:106
-Crash dump complete
 tester@127.0.0.1 logged out, country #1
 Connect from 127.0.0.1
 tester@127.0.0.1 using country #0