FIX strncpy warning in apps/cmp.c.
authorXiaofei Bai <xiaofei.bai@arm.com>
Tue, 15 Sep 2020 01:59:02 +0000 (01:59 +0000)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Thu, 17 Sep 2020 12:19:09 +0000 (14:19 +0200)
bugfix: #12872

strncpy here has compiling warning of -Wstringop-truncation, change
into BIO_snprintf as before.

Change-Id: I362872c4ad328cadd4c7a5a5da3165655fa26c0d

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/12889)

apps/cmp.c

index 083425c08f457e5024d6f001901bb1eb2ef90f7e..1137ed0a84520e5d07156b477ae379c5c3344295 100644 (file)
@@ -1839,7 +1839,7 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
         CMP_err("missing -tls_used option since -server URL indicates https");
         goto err;
     }
-    strncpy(server_port, port, sizeof(server_port));
+    BIO_snprintf(server_port, sizeof(server_port), "%s", port);
     used_path = opt_path != NULL ? opt_path : path;
     if (!OSSL_CMP_CTX_set1_server(ctx, server)
             || !OSSL_CMP_CTX_set_serverPort(ctx, portnum)