CID 22561: Copy into fixed size buffer (STRING_OVERFLOW)

This commit is contained in:
Enno Rehling 2015-10-30 11:45:20 +01:00
parent be0563c1f0
commit 68f8f0830e
1 changed files with 4 additions and 1 deletions

View File

@ -1773,7 +1773,10 @@ const char *trailinto(const region * r, const struct locale *lang)
const char *s; const char *s;
if (r) { if (r) {
const char *tname = terrain_name(r); const char *tname = terrain_name(r);
strcat(strcpy(ref, tname), "_trail"); size_t sz;
sz = strlcpy(ref, tname, sizeof(ref));
sz += strlcat(ref+sz, "_trail", sizeof(ref)-sz);
s = LOC(lang, ref); s = LOC(lang, ref);
if (s && *s) { if (s && *s) {
if (strstr(s, "%s")) if (strstr(s, "%s"))