usbvideo: limit the length of string creation
Commit Message
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>
---
--
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
Comments
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>
@@ -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) {
@@ -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) {