strncpy(dest, src, strlen(src)) leads to unterminated
dest, which is dangerous.
Fix it by using strscpy.
Signed-off-by: Chuhong Yuan <[email protected]>
---
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
On Tue, Jul 30, 2019 at 04:40:18PM +0800, Chuhong Yuan wrote:
> strncpy(dest, src, strlen(src)) leads to unterminated
> dest, which is dangerous.
> Fix it by using strscpy.
>
> Signed-off-by: Chuhong Yuan <[email protected]>
> ---
> tools/crypto/getstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
This file no longer exists in cryptodev.
Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt