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);
|
sprintf(zText, "%s_prefix_%d", monster, uv);
|
||||||
str = locale_getstring(default_locale, zText);
|
str = locale_getstring(default_locale, zText);
|
||||||
if (str) {
|
if (str) {
|
||||||
strcat(name, (const char *)str);
|
size_t sz = strlcpy(name, (const char *)str, sizeof(name));
|
||||||
strcat(name, " ");
|
strlcpy(name + sz, " ", sizeof(name) - sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(zText, "%s_name_%d", monster, uu);
|
sprintf(zText, "%s_name_%d", monster, uu);
|
||||||
str = locale_getstring(default_locale, zText);
|
str = locale_getstring(default_locale, zText);
|
||||||
if (str)
|
if (str)
|
||||||
strcat(name, (const char *)str);
|
strlcat(name, (const char *)str, sizeof(name));
|
||||||
|
|
||||||
if (un < *num_postfix) {
|
if (un < *num_postfix) {
|
||||||
sprintf(zText, "%s_postfix_%d", monster, un);
|
sprintf(zText, "%s_postfix_%d", monster, un);
|
||||||
str = locale_getstring(default_locale, zText);
|
str = locale_getstring(default_locale, zText);
|
||||||
if (str) {
|
if (str) {
|
||||||
strcat(name, " ");
|
strlcat(name, " ", sizeof(name));
|
||||||
strcat(name, (const char *)str);
|
strlcat(name, (const char *)str, sizeof(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|
Loading…
Reference in New Issue