linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbvideo: limit the length of string creation
@ 2009-11-21 17:02 Németh Márton
  2009-12-01 11:33 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Németh Márton @ 2009-11-21 17:02 UTC (permalink / raw)
  To: Laurent Pinchart, V4L Mailing List; +Cc: cocci, LKML

From: Márton Németh <nm127@freemail.hu>

Use strlcat() to append a string to the previously created first part.
The strlcat() function limits the size of the string to the whole
destination buffer.

The semantic match that finds this kind of problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression dev;
expression phys;
expression str;
expression size;
@@
 	usb_make_path(dev, phys, size);
-	strncat(phys, str, size);
+	strlcat(phys, str, size);
// </smpl>

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -u -p a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
--- a/drivers/media/video/usbvideo/konicawc.c 2009-09-10 00:13:59.000000000 +0200
+++ b/drivers/media/video/usbvideo/konicawc.c 2009-11-21 17:48:52.000000000 +0100
@@ -225,7 +225,7 @@ static void konicawc_register_input(stru
 	int error;

 	usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
-	strncat(cam->input_physname, "/input0", sizeof(cam->input_physname));
+	strlcat(cam->input_physname, "/input0", sizeof(cam->input_physname));

 	cam->input = input_dev = input_allocate_device();
 	if (!input_dev) {
diff -u -p a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
--- a/drivers/media/video/usbvideo/quickcam_messenger.c 2009-09-10 00:13:59.000000000 +0200
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c 2009-11-21 17:48:53.000000000 +0100
@@ -89,7 +89,7 @@ static void qcm_register_input(struct qc
 	int error;

 	usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
-	strncat(cam->input_physname, "/input0", sizeof(cam->input_physname));
+	strlcat(cam->input_physname, "/input0", sizeof(cam->input_physname));

 	cam->input = input_dev = input_allocate_device();
 	if (!input_dev) {

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

* Re: [PATCH] usbvideo: limit the length of string creation
  2009-11-21 17:02 [PATCH] usbvideo: limit the length of string creation Németh Márton
@ 2009-12-01 11:33 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2009-12-01 11:33 UTC (permalink / raw)
  To: Németh Márton; +Cc: V4L Mailing List, cocci, LKML

On Saturday 21 November 2009 18:02:56 Németh Márton wrote:
> From: Márton Németh <nm127@freemail.hu>
> 
> Use strlcat() to append a string to the previously created first part.
> The strlcat() function limits the size of the string to the whole
> destination buffer.
> 
> The semantic match that finds this kind of problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression dev;
> expression phys;
> expression str;
> expression size;
> @@
>  	usb_make_path(dev, phys, size);
> -	strncat(phys, str, size);
> +	strlcat(phys, str, size);
> // </smpl>
> 
> Signed-off-by: Márton Németh <nm127@freemail.hu>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2009-12-01 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-21 17:02 [PATCH] usbvideo: limit the length of string creation Németh Márton
2009-12-01 11:33 ` Laurent Pinchart

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).