From e69635d697311e9684e892b2c97616d623266c0b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 30 Oct 2015 11:02:51 +0100 Subject: [PATCH] CID 22569: Copy into fixed size buffer (STRING_OVERFLOW) bsdstring functions are the best. --- src/names.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/names.c b/src/names.c index df2e5e0a6..503d3f5ea 100644 --- a/src/names.c +++ b/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;