RDMA/efa: Use strscpy instead of strlcpy
Subsystems (2)
PATCH v2 1/1 RDMA/efa: Use strscpy instead of strlcpy
The strlcpy function doesn't limit the source length, use the preferred strscpy function instead.
Reviewed-by Firas JahJah <[email protected]>
Reviewed-by Yossi Leybovich <[email protected]>
Signed-off-by Gal Pressman <[email protected]>
---v1->v2: https://lore.kernel.org/linux-rdma/[email protected]/
* Remove the min() in the length argument (Jason)
--- drivers/infiniband/hw/efa/efa_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/hw/efa/efa_main.c +5 -5
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause /* -* Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved. +* Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved. */ #include <linux/module.h>
@@ -209,11 +209,11 @@ static void efa_set_host_info(struct efa_dev *dev)if (!hinf)return ; -strlcpy (hinf->os_dist_str,utsname ()->release, -min (sizeof (hinf->os_dist_str),sizeof (utsname ()->release))); +strscpy (hinf->os_dist_str,utsname ()->release, +sizeof (hinf->os_dist_str)); hinf->os_type =EFA_ADMIN_OS_LINUX ; -strlcpy (hinf->kernel_ver_str,utsname ()->version, -min (sizeof (hinf->kernel_ver_str),sizeof (utsname ()->version))); +strscpy (hinf->kernel_ver_str,utsname ()->version, +sizeof (hinf->kernel_ver_str)); hinf->kernel_ver =LINUX_VERSION_CODE ;EFA_SET (&hinf->driver_ver,EFA_ADMIN_HOST_INFO_DRIVER_MAJOR ,0 );EFA_SET (&hinf->driver_ver,EFA_ADMIN_HOST_INFO_DRIVER_MINOR ,0 );
base-commit: 783cf673b05ebf290317f583ee7eb6967ed9c964
Signature · 1 line
2.31.0
Quoted 6 lines · Gal Pressman
The strlcpy function doesn't limit the source length, use the preferred strscpy function instead.
Reviewed-by Firas JahJah <[email protected]>Reviewed-by Yossi Leybovich <[email protected]>Signed-off-by Gal Pressman <[email protected]>
Quoted 6 lines
---
v1->v2: https://lore.kernel.org/linux-rdma/[email protected]/
* Remove themin()in the length argument (Jason)--- drivers/infiniband/hw/efa/efa_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Applied to for-next, thanks
Jason