Remove use of strcpy() and sprintf().
[tinc] / src / utils.c
index 65ba4b9..c374eb5 100644 (file)
@@ -158,7 +158,7 @@ int b64encode_urlsafe(const void *src, char *dst, int length) {
 const char *winerror(int err) {
        static char buf[1024], *ptr;
 
-       ptr = buf + sprintf(buf, "(%d) ", err);
+       ptr = buf + snprintf(buf, sizeof buf, "(%d) ", err);
 
        if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), ptr, sizeof(buf) - (ptr - buf), NULL)) {