version: use msnprintf instead of strncpy

- to ensure a terminating null byte
- to avoid zero-padding the target

debug code only

Closes #13549
This commit is contained in:
Daniel Stenberg 2024-05-08 08:41:28 +02:00
parent cd3463d99e
commit 7c8970e95f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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