]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
put_str: Use memcpy instead of strncpy
authorTomas Mraz <tomas@openssl.org>
Wed, 22 Jun 2022 10:36:02 +0000 (12:36 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 23 Jun 2022 13:44:19 +0000 (15:44 +0200)
This fixes a warning from latest gcc.

There is no point in using strncpy here as we
intentionally copy only the string contents without
the terminating NUL. The len is set from strlen().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18627)

crypto/property/property_parse.c

index cdfe4777353aff3cc4a1072006265e1f7034d74a..b2bf3cd63180a92fa23f2db3c8b986ec2cf7262a 100644 (file)
@@ -600,7 +600,7 @@ static void put_str(const char *str, char **buf, size_t *remain, size_t *needed)
         len = *remain - 1;
 
     if (len > 0) {
-        strncpy(*buf, str, len);
+        memcpy(*buf, str, len);
         *buf += len;
         *remain -= len;
     }