bugfix buffer bounds

This commit is contained in:
Enno Rehling 2007-02-28 21:50:19 +00:00
parent 5104d7c4ca
commit c355a5d862
5 changed files with 6 additions and 6 deletions

View File

@ -235,7 +235,7 @@ alliancename(const alliance * al)
if (al && al->name) {
snprintf(ibuf, sizeof(name), "%s (%s)", strcheck(al->name, NAMESIZE), itoa36(al->id));
ibuf[sizeof(name)] = 0;
ibuf[sizeof(name)-1] = 0;
} else {
return NULL;
}

View File

@ -1821,7 +1821,7 @@ buildingname (const building * b)
char *ibuf = idbuf[(++nextbuf) % 8];
snprintf(ibuf, sizeof(ibuf), "%s (%s)", strcheck(b->name, NAMESIZE), itoa36(b->no));
ibuf[sizeof(name)] = 0;
ibuf[sizeof(name)-1] = 0;
return ibuf;
}
@ -1853,7 +1853,7 @@ unitname(const unit * u)
{
char *ubuf = idbuf[(++nextbuf) % 8];
snprintf(ubuf, sizeof(name), "%s (%s)", strcheck(u->name, NAMESIZE), itoa36(u->no));
ubuf[sizeof(name)] = 0;
ubuf[sizeof(name)-1] = 0;
return ubuf;
}

View File

@ -70,7 +70,7 @@ factionname(const faction * f)
if (f && f->name) {
snprintf(ibuf, sizeof(name), "%s (%s)", strcheck(f->name, NAMESIZE), itoa36(f->no));
ibuf[sizeof(name)] = 0;
ibuf[sizeof(name)-1] = 0;
} else {
strcpy(ibuf, "Unbekannte Partei (?)");
}

View File

@ -878,7 +878,7 @@ is_guarded(region * r, unit * u, unsigned int mask)
}
}
for (u2 = r->units; u2; u2 = u2->next) {
if (is_guardian(u2, u, mask)) {
if (u2!=guardcache && is_guardian(u2, u, mask)) {
guardcache = u2;
return u2;
}

View File

@ -1054,7 +1054,6 @@ readunit(FILE * F)
u->flags = ri(F) & ~UFL_DEBUG;
u->flags &= UFL_SAVEMASK;
}
if (u->flags&UFL_GUARD) fset(u->region, UFL_GUARD);
/* Persistente Befehle einlesen */
free_orders(&u->orders);
freadstr(F, buf, sizeof(buf));
@ -1917,6 +1916,7 @@ readgame(const char * filename, int backup)
assert(u->region==NULL);
u->region = r;
if (u->flags&UFL_GUARD) fset(r, RF_GUARDED);
*up = u;
up = &u->next;