Kampf crasht mit Datenfile 420

Da waren 50 Armeen in einer Region, das hat einen string-buffer auf dem stack von battle_report gekillt.
This commit is contained in:
Enno Rehling 2005-06-15 20:51:25 +00:00
parent b16bbb9146
commit a6ffd0f35b
1 changed files with 31 additions and 28 deletions

View File

@ -51,17 +51,17 @@
#include <items/demonseye.h> #include <items/demonseye.h>
/* util includes */ /* util includes */
#include <base36.h> #include <util/base36.h>
#include <cvector.h> #include <util/bsdstring.h>
#include <rand.h> #include <util/cvector.h>
#include <log.h> #include <util/rand.h>
#include <util/log.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <message.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -3284,7 +3284,7 @@ battle_report(battle * b)
side *s, *s2; side *s, *s2;
boolean cont = false; boolean cont = false;
boolean komma; boolean komma;
char buf2[1024]; char * bufp = buf;
bfaction *bf; bfaction *bf;
buf[0] = 0; buf[0] = 0;
@ -3314,7 +3314,6 @@ battle_report(battle * b)
message_faction(b, fac, m); message_faction(b, fac, m);
msg_release(m); msg_release(m);
buf2[0] = 0;
komma = false; komma = false;
cv_foreach(s, b->sides) { cv_foreach(s, b->sides) {
if (s->alive) { if (s->alive) {
@ -3322,25 +3321,29 @@ battle_report(battle * b)
int l = FIGHT_ROW; int l = FIGHT_ROW;
const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-"; const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-";
const char * loc_army = LOC(fac->locale, "battle_army"); const char * loc_army = LOC(fac->locale, "battle_army");
sprintf(buf, "%s%s %2d(%s): ", (komma==true?", ":""), char buffer[32];
if (komma) bufp += strlcpy(bufp, ", ", sizeof(buf) - (bufp - buf));
snprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
loc_army, s->index, abbrev); loc_army, s->index, abbrev);
buffer[sizeof(buffer)-1] = 0;
bufp += strlcpy(bufp, buffer, sizeof(buf) - (bufp - buf));
for (r=FIGHT_ROW;r!=NUMROWS;++r) { for (r=FIGHT_ROW;r!=NUMROWS;++r) {
if (alive[r]) { if (alive[r]) {
if (l!=FIGHT_ROW) scat("+"); if (l!=FIGHT_ROW) scat("+");
while(k--) scat("0+"); while(k--) scat("0+");
icat(alive[r]); icat(alive[r]);
k = 0; k = 0;
l=r+1; l = r+1;
} else ++k; } else ++k;
} }
strcat(buf2, buf);
if (komma == false) {
komma = true; komma = true;
} }
}
} cv_next(s); } cv_next(s);
fbattlerecord(b, fac, buf2); fbattlerecord(b, fac, buf);
} }
return cont; return cont;
} }