forked from github/server
CID 22569: Copy into fixed size buffer (STRING_OVERFLOW)
bsdstring functions are the best.
This commit is contained in:
parent
4ee0f76927
commit
e69635d697
10
src/names.c
10
src/names.c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue