diff --git a/client/util.c b/client/util.c index 856091231..e07fe5d21 100644 --- a/client/util.c +++ b/client/util.c @@ -918,13 +918,13 @@ void strcreplace(char *buf, size_t len, char from, char to) { } } -char *strmcopy(const char *buf) { - char *str = (char *) calloc(strlen(buf) + 1, sizeof(uint8_t)); - if (str != NULL) { - memset(str, 0, strlen(buf) + 1); - strcpy(str, buf); +char *strmcopy(const char *src) { + char *dest = (char *) calloc(strlen(src) + 1, sizeof(uint8_t)); + if (dest != NULL) { + memset(dest, 0, strlen(src) + 1); + strncat(dest, src, strlen(src)); } - return str; + return dest; } /** diff --git a/client/util.h b/client/util.h index afa12811b..043f08e5d 100644 --- a/client/util.h +++ b/client/util.h @@ -99,6 +99,6 @@ bool str_endswith(const char *s, const char *suffix); // check for suffix in void clean_ascii(unsigned char *buf, size_t len); void strcleanrn(char *buf, size_t len); void strcreplace(char *buf, size_t len, char from, char to); -char *strmcopy(const char *buf); +char *strmcopy(const char *src); int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str); #endif