From 7c8970e95f90bcfa7884dd019e085cef6ea09051 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 May 2024 08:41:28 +0200 Subject: [PATCH] version: use msnprintf instead of strncpy - to ensure a terminating null byte - to avoid zero-padding the target debug code only Closes #13549 --- lib/version.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/version.c b/lib/version.c index 66371923a7..a5c8c4e613 100644 --- a/lib/version.c +++ b/lib/version.c @@ -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 -- 2.47.3