tool_getparam: replace two uses of strncpy(), ban strncpy

strncpy() is rarely the right choice

Closes #15212
This commit is contained in:
Daniel Stenberg 2024-10-09 15:45:32 +02:00
parent 5ee43bb82e
commit 08949637d5
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 3 additions and 2 deletions

View File

@ -1 +1,2 @@
enable STDERR
enable STRNCPY

View File

@ -390,7 +390,7 @@ void parse_cert_parameter(const char *cert_parameter,
param_place = cert_parameter;
while(*param_place) {
span = strcspn(param_place, ":\\");
strncpy(certname_place, param_place, span);
memcpy(certname_place, param_place, span);
param_place += span;
certname_place += span;
/* we just ate all the non-special chars. now we are on either a special
@ -944,7 +944,7 @@ static ParameterError set_rate(struct GlobalConfig *global,
if(numlen > sizeof(number) -1)
return PARAM_NUMBER_TOO_LARGE;
strncpy(number, nextarg, numlen);
memcpy(number, nextarg, numlen);
number[numlen] = 0;
err = str2unum(&denominator, number);
if(err)