CID 22569: Copy into fixed size buffer (STRING_OVERFLOW)

bsdstring functions are the best.
This commit is contained in:
Enno Rehling 2015-10-30 11:02:51 +01:00
parent 4ee0f76927
commit e69635d697
1 changed files with 5 additions and 5 deletions

View File

@ -103,22 +103,22 @@ static const char *make_names(const char *monster, int *num_postfix,
sprintf(zText, "%s_prefix_%d", monster, uv);
str = locale_getstring(default_locale, zText);
if (str) {
strcat(name, (const char *)str);
strcat(name, " ");
size_t sz = strlcpy(name, (const char *)str, sizeof(name));
strlcpy(name + sz, " ", sizeof(name) - sz);
}
}
sprintf(zText, "%s_name_%d", monster, uu);
str = locale_getstring(default_locale, zText);
if (str)
strcat(name, (const char *)str);
strlcat(name, (const char *)str, sizeof(name));
if (un < *num_postfix) {
sprintf(zText, "%s_postfix_%d", monster, un);
str = locale_getstring(default_locale, zText);
if (str) {
strcat(name, " ");
strcat(name, (const char *)str);
strlcat(name, " ", sizeof(name));
strlcat(name, (const char *)str, sizeof(name));
}
}
return name;