]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_getparam: replace two uses of strncpy(), ban strncpy
authorDaniel Stenberg <daniel@haxx.se>
Wed, 9 Oct 2024 13:45:32 +0000 (15:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 9 Oct 2024 21:43:24 +0000 (23:43 +0200)
strncpy() is rarely the right choice

Closes #15212

src/.checksrc
src/tool_getparam.c

index 946367c4999f6f2961afc23db1d2bfb4211b2443..df9b1f0795a728fc34715b399e84208e5f56775a 100644 (file)
@@ -1 +1,2 @@
 enable STDERR
+enable STRNCPY
index 9a5de1e731e4773ba3f2db63168c0dda9ce5539f..7b6aea70a96529f8098f4abd645e624af0a6424d 100644 (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)