Details
[Home]
Issue of the Implementation # L0006
Brief
drivers/media/video/usbvideo/quickcam_messenger.c: Possible buffer overflow while use strncat with wrong 3rd parameter.
Detailed Description
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 used strncat:
92 strncat(cam->input_physname, "/input0", sizeof(cam- >input_physname));where sizeof(cam->input_physname) returned length of cam->input_phisname without length for nul-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 calls usb_make_path in similar drivers uses strlcat, like as: (example from drivers/hid/usbhid/hid-core.c):
1152 usb_make_path(dev, hid->phys, sizeof(hid->phys)); 1153 strlcat(hid->phys, "/input", sizeof(hid->phys));
Possible solutions
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) {
Component
linux-kernel 2.6.31
Accepted
http://lkml.org/lkml/2009/10/7/217
commit
Status
Fixed in kernel 2.6.33-rc1
[Home]
»