]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
version: use msnprintf instead of strncpy
authorDaniel Stenberg <daniel@haxx.se>
Wed, 8 May 2024 06:41:28 +0000 (08:41 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 8 May 2024 08:40:58 +0000 (10:40 +0200)
- to ensure a terminating null byte
- to avoid zero-padding the target

debug code only

Closes #13549

lib/version.c

index 66371923a732577f80cc2ae3537c53fd5b55b912..a5c8c4e61375c2965b5f94c4887ff13ddde858f2 100644 (file)
@@ -175,8 +175,7 @@ char *curl_version(void)
   /* Override version string when environment variable CURL_VERSION is set */
   const char *debugversion = getenv("CURL_VERSION");
   if(debugversion) {
-    strncpy(out, debugversion, sizeof(out)-1);
-    out[sizeof(out)-1] = '\0';
+    msnprintf(out, sizeof(out), "%s", debugversion);
     return out;
   }
 #endif