From: Chuhong Yuan <hslester96@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Corentin Labbe <clabbe@baylibre.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-kernel@vger.kernel.org, Chuhong Yuan <hslester96@gmail.com>
Subject: [PATCH] crypto: tool: getstat: Fix unterminated strncpy
Date: Tue, 30 Jul 2019 16:40:18 +0800 [thread overview]
Message-ID: <20190730084018.26374-1-hslester96@gmail.com> (raw)
strncpy(dest, src, strlen(src)) leads to unterminated
dest, which is dangerous.
Fix it by using strscpy.
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
tools/crypto/getstat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/crypto/getstat.c b/tools/crypto/getstat.c
index 9e8ff76420fa..554ba08d9652 100644
--- a/tools/crypto/getstat.c
+++ b/tools/crypto/getstat.c
@@ -41,7 +41,7 @@ static int get_stat(const char *drivername)
req.n.nlmsg_type = CRYPTO_MSG_GETSTAT;
req.n.nlmsg_seq = time(NULL);
- strncpy(req.cru.cru_driver_name, drivername, strlen(drivername));
+ strscpy(req.cru.cru_driver_name, drivername, strlen(drivername) + 1);
sd = socket(AF_NETLINK, SOCK_RAW, NETLINK_CRYPTO);
if (sd < 0) {
--
2.20.1
next reply other threads:[~2019-07-30 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 8:40 Chuhong Yuan [this message]
2019-07-30 11:35 ` [PATCH] crypto: tool: getstat: Fix unterminated strncpy Herbert Xu
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=20190730084018.26374-1-hslester96@gmail.com \
--to=hslester96@gmail.com \
--cc=clabbe@baylibre.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.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