summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-08-20 09:03:45 +1000
committerNathan Scott <nathans@redhat.com>2020-08-20 09:03:45 +1000
commit5228f5d47a10d9194297a31bf4cf7dbbade6c868 (patch)
tree663fa042746ea416d1c0ee0f72373596c10af001
parent74d547674d50b8b0f0c2fc64608a95a1049bad4c (diff)
Ensure result buffer termination in String_cat utility routine
-rw-r--r--StringUtils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/StringUtils.c b/StringUtils.c
index 0578cdea..84b69b64 100644
--- a/StringUtils.c
+++ b/StringUtils.c
@@ -30,8 +30,9 @@ char* String_cat(const char* s1, const char* s2) {
int l1 = strlen(s1);
int l2 = strlen(s2);
char* out = xMalloc(l1 + l2 + 1);
- strncpy(out, s1, l1);
- strncpy(out+l1, s2, l2+1);
+ memcpy(out, s1, l1);
+ memcpy(out+l1, s2, l2+1);
+ out[l1 + l2] = '\0';
return out;
}