patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ruifeng Wang <ruifeng.wang@arm.com>
To: kai.ji@intel.com, fanzhang.oss@gmail.com, gakhil@marvell.com
Cc: dev@dpdk.org, stable@dpdk.org, david.marchand@redhat.com,
	feifei.wang2@arm.com, nd@arm.com,
	Ruifeng Wang <ruifeng.wang@arm.com>
Subject: [PATCH v2] crypto/openssl: fix warning on copy length
Date: Mon,  9 Jan 2023 11:40:21 +0800	[thread overview]
Message-ID: <20230109034021.2759215-1-ruifeng.wang@arm.com> (raw)
In-Reply-To: <20230106101520.2736826-1-ruifeng.wang@arm.com>

When building with gcc 11.2.0, the compiler warns as follows:
In function 'memcpy',
    inlined from 'openssl_set_session_auth_parameters' at ../drivers/crypto/openssl/rte_openssl_pmd.c:699:3,
    inlined from 'openssl_set_session_parameters' at ../drivers/crypto/openssl/rte_openssl_pmd.c:826:9:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:29:10: warning: '__builtin_memcpy' forming offset [4, 8] is out of the bounds [0, 4] [-Warray-bounds]

Fixed the warning by copying up to string / buffer size.

Fixes: 75adf1eae44f ("crypto/openssl: update HMAC routine with 3.0 EVP API")
Cc: stable@dpdk.org
Cc: kai.ji@intel.com

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 05449b6e98..abcb641a44 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -696,7 +696,7 @@ openssl_set_session_auth_parameters(struct openssl_session *sess,
 		algo = digest_name_get(xform->auth.algo);
 		if (!algo)
 			return -EINVAL;
-		rte_memcpy(algo_name, algo, (sizeof(algo)+1));
+		strlcpy(algo_name, algo, sizeof(algo_name));
 
 		mac = EVP_MAC_fetch(NULL, "HMAC", NULL);
 		sess->auth.hmac.ctx = EVP_MAC_CTX_new(mac);
-- 
2.25.1


  parent reply	other threads:[~2023-01-09  3:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 10:15 [PATCH] " Ruifeng Wang
2023-01-06 10:26 ` David Marchand
2023-01-09  3:31   ` Ruifeng Wang
2023-01-09  3:40 ` Ruifeng Wang [this message]
2023-01-31  8:09   ` [EXT] [PATCH v2] " Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230109034021.2759215-1-ruifeng.wang@arm.com \
    --to=ruifeng.wang@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=feifei.wang2@arm.com \
    --cc=gakhil@marvell.com \
    --cc=kai.ji@intel.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).