staging: most: protect potential string overflow
Subsystems (2)
PATCH 1/1 staging: most: protect potential string overflow
There maybe cause potential string overflow issue due to use strcpy without checking the length
Detected By CoversityScan CID# 1444760
--- drivers/staging/most/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/core.c +1 -1
@@ -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;
Signature · 1 line
2.11.0
Quoted 6 lines · Bo YU
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.
Quoted 10 lines
Signed-off-by Bo YU <[email protected]>--- drivers/staging/most/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/most/core.c +0
-0
drivers/staging/most/core.c int most_register_interface(struct most_interface *iface) · line 1434
Quoted 5 lines
drivers/staging/most/core.c +1
-1@@ -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
Quoted 23 lines · Dan Carpenter
Quoted 6 lines · Bo YU
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.
Quoted 11 lines
Signed-off-by Bo YU <[email protected]>--- drivers/staging/most/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/most/core.c +0
-0@@ -1431,7 +1431,7 @@ int most_register_interface(struct most_interface *iface)
Quoted 6 lines
drivers/staging/most/core.c int most_register_interface(struct most_interface *iface) · line 1434
Quoted 4 lines
drivers/staging/most/core.c +1
-1INIT_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 thanstrlcpy()these days.
Ok,will try it.
Thanks,
Quoted 4 lines
regards,
dan carpenter