* [PATCH] quickcam_messenger.c: possible buffer overflow while use strncat.
@ 2009-10-07 15:56 Alexander Strakh
0 siblings, 0 replies; only message in thread
From: Alexander Strakh @ 2009-10-07 15:56 UTC (permalink / raw)
To: Jaya Kumar, Mauro Carvalho Chehab, linux-media, linux-kernel
In driver ./drivers/media/video/usbvideo/quickcam_messenger.c in line 91:
91 usb_make_path(dev, cam->input_physname, sizeof(cam-
>input_physname));
After this line we use strncat:
92 strncat(cam->input_physname, "/input0", sizeof(cam-
>input_physname));
where sizeof(cam->input_physname) returns length of cam->input_phisname
without length for null-symbol. But this parameter must be - "maximum numbers
of bytes to copy", i.e.: sizeof(cam->input_physname)-strlen(cam-
>input_physname)-1.
In this case, after call to usb_make_path the similar drivers use strlcat.
Like in: drivers/hid/usbhid/hid-core.c:
1152 usb_make_path(dev, hid->phys, sizeof(hid->phys));
1153 strlcat(hid->phys, "/input", sizeof(hid->phys));
Found by Linux Driver Verification Project.
Use strlcat instead of strncat.
Signed-off-by:Alexander Strakh <strakh@ispras.ru>
---
diff --git a/./a/drivers/media/video/usbvideo/quickcam_messenger.c
b/./b/drivers/media/video/usbvideo/quickcam_messenger.c
index 803d3e4..c4d1b96 100644
--- a/./a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/./b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -89,7 +89,7 @@ static void qcm_register_input(struct qcm *cam, struct
usb_device *dev)
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 related [flat|nested] only message in thread
only message in thread, other threads:[~2009-10-07 11:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07 15:56 [PATCH] quickcam_messenger.c: possible buffer overflow while use strncat Alexander Strakh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.