linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: most: protect potential string overflow
@ 2019-04-23  2:20 Bo YU
  2019-04-24 14:55 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Bo YU @ 2019-04-23  2:20 UTC (permalink / raw)
  To: gregkh, christian.gromm, colin.king, andrey.shvetsov
  Cc: Bo YU, devel, linux-kernel

There maybe cause potential string overflow issue due to use
strcpy without checking the length

Detected By CoversityScan CID# 1444760

Fixes: 131ac62253dba:(staging: most: core: use device description as name)
Signed-off-by: Bo YU <tsu.yubo@gmail.com>
---
 drivers/staging/most/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 956daf8c3bd2..0f26cebac91a 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1431,7 +1431,7 @@ int most_register_interface(struct most_interface *iface)
 
 	INIT_LIST_HEAD(&iface->p->channel_list);
 	iface->p->dev_id = id;
-	strcpy(iface->p->name, iface->description);
+	strlcpy(iface->p->name, iface->description, sizeof(iface->p->name));
 	iface->dev.init_name = iface->p->name;
 	iface->dev.bus = &mc.bus;
 	iface->dev.parent = &mc.dev;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: most: protect potential string overflow
  2019-04-23  2:20 [PATCH] staging: most: protect potential string overflow Bo YU
@ 2019-04-24 14:55 ` Dan Carpenter
  2019-04-26  3:44   ` Bo YU
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-04-24 14:55 UTC (permalink / raw)
  To: Bo YU
  Cc: gregkh, christian.gromm, colin.king, andrey.shvetsov, devel,
	linux-kernel

On Mon, Apr 22, 2019 at 10:20:18PM -0400, Bo YU wrote:
> There maybe cause potential string overflow issue due to use
> strcpy without checking the length
> 
> Detected By CoversityScan CID# 1444760
> 
> Fixes: 131ac62253dba:(staging: most: core: use device description as name)

It doesn't really fix anything, it just silences a static checker
warning.

> Signed-off-by: Bo YU <tsu.yubo@gmail.com>
> ---
>  drivers/staging/most/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
> index 956daf8c3bd2..0f26cebac91a 100644
> --- a/drivers/staging/most/core.c
> +++ b/drivers/staging/most/core.c
> @@ -1431,7 +1431,7 @@ int most_register_interface(struct most_interface *iface)
>  
>  	INIT_LIST_HEAD(&iface->p->channel_list);
>  	iface->p->dev_id = id;
> -	strcpy(iface->p->name, iface->description);
> +	strlcpy(iface->p->name, iface->description, sizeof(iface->p->name));

We prefer strscpy() more than strlcpy() these days.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: most: protect potential string overflow
  2019-04-24 14:55 ` Dan Carpenter
@ 2019-04-26  3:44   ` Bo YU
  0 siblings, 0 replies; 3+ messages in thread
From: Bo YU @ 2019-04-26  3:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Kroah-Hartman, christian.gromm, Colin King, andrey.shvetsov,
	open list:STAGING SUBSYSTEM, open list

On Wed, Apr 24, 2019 at 10:55 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Mon, Apr 22, 2019 at 10:20:18PM -0400, Bo YU wrote:
> > There maybe cause potential string overflow issue due to use
> > strcpy without checking the length
> >
> > Detected By CoversityScan CID# 1444760
> >
> > Fixes: 131ac62253dba:(staging: most: core: use device description as name)
>
> It doesn't really fix anything, it just silences a static checker
> warning.
>
> > Signed-off-by: Bo YU <tsu.yubo@gmail.com>
> > ---
> >  drivers/staging/most/core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
> > index 956daf8c3bd2..0f26cebac91a 100644
> > --- a/drivers/staging/most/core.c
> > +++ b/drivers/staging/most/core.c
> > @@ -1431,7 +1431,7 @@ int most_register_interface(struct most_interface *iface)
> >
> >       INIT_LIST_HEAD(&iface->p->channel_list);
> >       iface->p->dev_id = id;
> > -     strcpy(iface->p->name, iface->description);
> > +     strlcpy(iface->p->name, iface->description, sizeof(iface->p->name));
>
> We prefer strscpy() more than strlcpy() these days.

 Ok,will try it.
 Thanks,

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-26  3:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23  2:20 [PATCH] staging: most: protect potential string overflow Bo YU
2019-04-24 14:55 ` Dan Carpenter
2019-04-26  3:44   ` Bo YU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).