Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-10 Thread Eric Biggers
On Sun, Jun 07, 2020 at 01:03:45PM +, David Laight wrote: > From: Herbert Xu > > Sent: 05 June 2020 13:17 > ... > > Better yet use strscpy which will even return an error for you. > > It really ought to return the buffer length on truncation. > Then you can loop: > while(...) >

RE: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-07 Thread David Laight
From: Herbert Xu > Sent: 05 June 2020 13:17 ... > Better yet use strscpy which will even return an error for you. It really ought to return the buffer length on truncation. Then you can loop: while(...) buf += strxxxcpy(buf, src, buf_end - buf); and only check right at the

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-05 Thread Zhangfei Gao
On 2020/6/5 下午11:49, Eric Biggers wrote: On Fri, Jun 05, 2020 at 11:26:20PM +0800, Zhangfei Gao wrote: 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,

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-05 Thread Eric Biggers
On Fri, Jun 05, 2020 at 11:26:20PM +0800, Zhangfei Gao wrote: > > > 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, > > >

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-05 Thread Zhangfei Gao
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))  

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-05 Thread Herbert Xu
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

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-05 Thread Zhangfei Gao
On 2020/6/4 下午2:50, Herbert Xu wrote: On Thu, Jun 04, 2020 at 02:44:16PM +0800, Zhangfei Gao wrote: I think it is fine. 1. Currently the name size is 64, bigger enough. Simply grep in driver name, 64 should be enough. We can make it larger when there is a request. 2. it does not matter what

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-04 Thread Zhou Wang
On 2020/6/4 14:50, Herbert Xu wrote: > On Thu, Jun 04, 2020 at 02:44:16PM +0800, Zhangfei Gao wrote: >> >> I think it is fine. >> 1. Currently the name size is 64, bigger enough. >> Simply grep in driver name, 64 should be enough. >> We can make it larger when there is a request. >> 2. it does not

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-04 Thread Herbert Xu
On Thu, Jun 04, 2020 at 02:44:16PM +0800, Zhangfei Gao wrote: > > I think it is fine. > 1. Currently the name size is 64, bigger enough. > Simply grep in driver name, 64 should be enough. > We can make it larger when there is a request. > 2. it does not matter what the name is, since it is just an

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-04 Thread Zhangfei Gao
On 2020/6/4 下午2:18, Herbert Xu wrote: On Thu, Jun 04, 2020 at 02:10:37PM +0800, Zhangfei Gao wrote: Should this even allow truncation? Perhaps it'd be better to fail in case of an overrun? I think we do not need consider overrun, since it at most copy size-1 bytes to dest. From the manual:

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-04 Thread Herbert Xu
On Thu, Jun 04, 2020 at 02:10:37PM +0800, Zhangfei Gao wrote: > > > Should this even allow truncation? Perhaps it'd be better to fail > > in case of an overrun? > I think we do not need consider overrun, since it at most copy size-1 bytes > to dest. > From the manual: strlcpy() >    This 

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-04 Thread Zhangfei Gao
On 2020/6/4 上午11:39, Herbert Xu wrote: On Thu, Jun 04, 2020 at 11:32:04AM +0800, Zhangfei Gao wrote: Use strlcpy to fix the warning warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation] Reported-by: kernel test robot Signed-off-by: Zhangfei Gao

Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-03 Thread Herbert Xu
On Thu, Jun 04, 2020 at 11:32:04AM +0800, Zhangfei Gao wrote: > Use strlcpy to fix the warning > warning: 'strncpy' specified bound 64 equals destination size > [-Wstringop-truncation] > > Reported-by: kernel test robot > Signed-off-by: Zhangfei Gao > --- >

[PATCH] crypto: hisilicon - fix strncpy warning with strlcpy

2020-06-03 Thread Zhangfei Gao
Use strlcpy to fix the warning warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation] Reported-by: kernel test robot Signed-off-by: Zhangfei Gao --- drivers/crypto/hisilicon/qm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git