[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47b747d2-3b27-4f39-85c9-204c2b8a92e1@linaro.org>
Date: Fri, 5 Jun 2020 23:26:20 +0800
From: Zhangfei Gao <zhangfei.gao@...aro.org>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
wangzhou1 <wangzhou1@...ilicon.com>,
linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
kbuild-all@...ts.01.org
Subject: Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy
On 2020/6/5 下午8:17, Herbert Xu wrote:
> On Fri, Jun 05, 2020 at 05:34:32PM +0800, Zhangfei Gao wrote:
>> Will add a check after the copy.
>>
>> strlcpy(interface.name, pdev->driver->name, sizeof(interface.name));
>> if (strlen(pdev->driver->name) != strlen(interface.name))
>> return -EINVAL;
> You don't need to do strlen. The function strlcpy returns the
> length of the source string.
>
> Better yet use strscpy which will even return an error for you.
>
>
Yes, good idea, we can use strscpy.
+ int ret;
- strncpy(interface.name, pdev->driver->name, sizeof(interface.name));
+ ret = strscpy(interface.name, pdev->driver->name,
sizeof(interface.name));
+ if (ret < 0)
+ return ret;
Will resend later, thanks Herbert.
Powered by blists - more mailing lists