diff mbox

[media] stk1160: warrant a NUL terminated string

Message ID 1396878140-22084-1-git-send-email-m.chehab@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab April 7, 2014, 1:42 p.m. UTC
strncpy() doesn't warrant a NUL terminated string. Use
strlcpy() instead.

Fixes Coverity bug CID#1195195.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
 drivers/media/usb/stk1160/stk1160-ac97.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hans Verkuil April 7, 2014, 1:45 p.m. UTC | #1
On 04/07/2014 03:42 PM, Mauro Carvalho Chehab wrote:
> strncpy() doesn't warrant a NUL terminated string. Use
> strlcpy() instead.
> 
> Fixes Coverity bug CID#1195195.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

My good deed for the day:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/usb/stk1160/stk1160-ac97.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
> index c46c8be89602..2dd308f9541f 100644
> --- a/drivers/media/usb/stk1160/stk1160-ac97.c
> +++ b/drivers/media/usb/stk1160/stk1160-ac97.c
> @@ -108,7 +108,7 @@ int stk1160_ac97_register(struct stk1160 *dev)
>  		 "stk1160-mixer");
>  	snprintf(card->longname, sizeof(card->longname),
>  		 "stk1160 ac97 codec mixer control");
> -	strncpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
> +	strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
>  
>  	rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus);
>  	if (rc)
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ezequiel Garcia April 7, 2014, 3:08 p.m. UTC | #2
On Apr 07, Mauro Carvalho Chehab wrote:
> strncpy() doesn't warrant a NUL terminated string. Use
> strlcpy() instead.
> 
> Fixes Coverity bug CID#1195195.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> ---
>  drivers/media/usb/stk1160/stk1160-ac97.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
> index c46c8be89602..2dd308f9541f 100644
> --- a/drivers/media/usb/stk1160/stk1160-ac97.c
> +++ b/drivers/media/usb/stk1160/stk1160-ac97.c
> @@ -108,7 +108,7 @@ int stk1160_ac97_register(struct stk1160 *dev)
>  		 "stk1160-mixer");
>  	snprintf(card->longname, sizeof(card->longname),
>  		 "stk1160 ac97 codec mixer control");
> -	strncpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
> +	strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
>  
>  	rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus);
>  	if (rc)

Shame on me.

Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
diff mbox

Patch

diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
index c46c8be89602..2dd308f9541f 100644
--- a/drivers/media/usb/stk1160/stk1160-ac97.c
+++ b/drivers/media/usb/stk1160/stk1160-ac97.c
@@ -108,7 +108,7 @@  int stk1160_ac97_register(struct stk1160 *dev)
 		 "stk1160-mixer");
 	snprintf(card->longname, sizeof(card->longname),
 		 "stk1160 ac97 codec mixer control");
-	strncpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
+	strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
 
 	rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus);
 	if (rc)