aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/uvc
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@skynet.be>2009-01-08 12:05:11 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:26 -0400
commitd0ebf3073f8812464c9f6014d6cee09ab37c3fb5 (patch)
treecae1337ef45a319301a668c7cf16918283e6dbb4 /drivers/media/video/uvc
parent07f7db4ce7b29d431553b426e0dcb720c5297a4b (diff)
V4L/DVB (10293): uvcvideo: replace strn{cpy,cat} with strl{cpy,cat}.
strncpy is unsafe as it doesn't append a terminating NUL character when the source string doesn't fit in the destination buffer. Replace it with strlcpy. strncat is misused as its size argument refers to the source string, not the destination buffer. Replace it with strlcat. Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc')
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c2
-rw-r--r--drivers/media/video/uvc/uvc_driver.c16
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c12
3 files changed, 15 insertions, 15 deletions
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index d2576f6391c0..0d7e38d6ff6a 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -786,7 +786,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
786 memset(v4l2_ctrl, 0, sizeof *v4l2_ctrl); 786 memset(v4l2_ctrl, 0, sizeof *v4l2_ctrl);
787 v4l2_ctrl->id = mapping->id; 787 v4l2_ctrl->id = mapping->id;
788 v4l2_ctrl->type = mapping->v4l2_type; 788 v4l2_ctrl->type = mapping->v4l2_type;
789 strncpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name); 789 strlcpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name);
790 v4l2_ctrl->flags = 0; 790 v4l2_ctrl->flags = 0;
791 791
792 if (!(ctrl->info->flags & UVC_CONTROL_SET_CUR)) 792 if (!(ctrl->info->flags & UVC_CONTROL_SET_CUR))
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index b12873265cc5..6dba5ead8836 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -314,7 +314,7 @@ static int uvc_parse_format(struct uvc_device *dev,
314 fmtdesc = uvc_format_by_guid(&buffer[5]); 314 fmtdesc = uvc_format_by_guid(&buffer[5]);
315 315
316 if (fmtdesc != NULL) { 316 if (fmtdesc != NULL) {
317 strncpy(format->name, fmtdesc->name, 317 strlcpy(format->name, fmtdesc->name,
318 sizeof format->name); 318 sizeof format->name);
319 format->fcc = fmtdesc->fcc; 319 format->fcc = fmtdesc->fcc;
320 } else { 320 } else {
@@ -345,7 +345,7 @@ static int uvc_parse_format(struct uvc_device *dev,
345 return -EINVAL; 345 return -EINVAL;
346 } 346 }
347 347
348 strncpy(format->name, "MJPEG", sizeof format->name); 348 strlcpy(format->name, "MJPEG", sizeof format->name);
349 format->fcc = V4L2_PIX_FMT_MJPEG; 349 format->fcc = V4L2_PIX_FMT_MJPEG;
350 format->flags = UVC_FMT_FLAG_COMPRESSED; 350 format->flags = UVC_FMT_FLAG_COMPRESSED;
351 format->bpp = 0; 351 format->bpp = 0;
@@ -363,13 +363,13 @@ static int uvc_parse_format(struct uvc_device *dev,
363 363
364 switch (buffer[8] & 0x7f) { 364 switch (buffer[8] & 0x7f) {
365 case 0: 365 case 0:
366 strncpy(format->name, "SD-DV", sizeof format->name); 366 strlcpy(format->name, "SD-DV", sizeof format->name);
367 break; 367 break;
368 case 1: 368 case 1:
369 strncpy(format->name, "SDL-DV", sizeof format->name); 369 strlcpy(format->name, "SDL-DV", sizeof format->name);
370 break; 370 break;
371 case 2: 371 case 2:
372 strncpy(format->name, "HD-DV", sizeof format->name); 372 strlcpy(format->name, "HD-DV", sizeof format->name);
373 break; 373 break;
374 default: 374 default:
375 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" 375 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming"
@@ -379,7 +379,7 @@ static int uvc_parse_format(struct uvc_device *dev,
379 return -EINVAL; 379 return -EINVAL;
380 } 380 }
381 381
382 strncat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz", 382 strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz",
383 sizeof format->name); 383 sizeof format->name);
384 384
385 format->fcc = V4L2_PIX_FMT_DV; 385 format->fcc = V4L2_PIX_FMT_DV;
@@ -1526,7 +1526,7 @@ static int uvc_register_video(struct uvc_device *dev)
1526 vdev->minor = -1; 1526 vdev->minor = -1;
1527 vdev->fops = &uvc_fops; 1527 vdev->fops = &uvc_fops;
1528 vdev->release = video_device_release; 1528 vdev->release = video_device_release;
1529 strncpy(vdev->name, dev->name, sizeof vdev->name); 1529 strlcpy(vdev->name, dev->name, sizeof vdev->name);
1530 1530
1531 /* Set the driver data before calling video_register_device, otherwise 1531 /* Set the driver data before calling video_register_device, otherwise
1532 * uvc_v4l2_open might race us. 1532 * uvc_v4l2_open might race us.
@@ -1621,7 +1621,7 @@ static int uvc_probe(struct usb_interface *intf,
1621 dev->quirks = id->driver_info | uvc_quirks_param; 1621 dev->quirks = id->driver_info | uvc_quirks_param;
1622 1622
1623 if (udev->product != NULL) 1623 if (udev->product != NULL)
1624 strncpy(dev->name, udev->product, sizeof dev->name); 1624 strlcpy(dev->name, udev->product, sizeof dev->name);
1625 else 1625 else
1626 snprintf(dev->name, sizeof dev->name, 1626 snprintf(dev->name, sizeof dev->name,
1627 "UVC Camera (%04x:%04x)", 1627 "UVC Camera (%04x:%04x)",
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index d681519d0c8a..011ebd4da44a 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -55,7 +55,7 @@ static int uvc_v4l2_query_menu(struct uvc_video_device *video,
55 return -EINVAL; 55 return -EINVAL;
56 56
57 menu_info = &mapping->menu_info[query_menu->index]; 57 menu_info = &mapping->menu_info[query_menu->index];
58 strncpy(query_menu->name, menu_info->name, 32); 58 strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);
59 return 0; 59 return 0;
60} 60}
61 61
@@ -486,9 +486,9 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
486 struct v4l2_capability *cap = arg; 486 struct v4l2_capability *cap = arg;
487 487
488 memset(cap, 0, sizeof *cap); 488 memset(cap, 0, sizeof *cap);
489 strncpy(cap->driver, "uvcvideo", sizeof cap->driver); 489 strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);
490 strncpy(cap->card, vdev->name, 32); 490 strlcpy(cap->card, vdev->name, sizeof cap->card);
491 strncpy(cap->bus_info, video->dev->udev->bus->bus_name, 491 strlcpy(cap->bus_info, video->dev->udev->bus->bus_name,
492 sizeof cap->bus_info); 492 sizeof cap->bus_info);
493 cap->version = DRIVER_VERSION_NUMBER; 493 cap->version = DRIVER_VERSION_NUMBER;
494 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 494 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -620,7 +620,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
620 620
621 memset(input, 0, sizeof *input); 621 memset(input, 0, sizeof *input);
622 input->index = index; 622 input->index = index;
623 strncpy(input->name, iterm->name, sizeof input->name); 623 strlcpy(input->name, iterm->name, sizeof input->name);
624 if (UVC_ENTITY_TYPE(iterm) == ITT_CAMERA) 624 if (UVC_ENTITY_TYPE(iterm) == ITT_CAMERA)
625 input->type = V4L2_INPUT_TYPE_CAMERA; 625 input->type = V4L2_INPUT_TYPE_CAMERA;
626 break; 626 break;
@@ -682,7 +682,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
682 fmt->flags = 0; 682 fmt->flags = 0;
683 if (format->flags & UVC_FMT_FLAG_COMPRESSED) 683 if (format->flags & UVC_FMT_FLAG_COMPRESSED)
684 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED; 684 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
685 strncpy(fmt->description, format->name, 685 strlcpy(fmt->description, format->name,
686 sizeof fmt->description); 686 sizeof fmt->description);
687 fmt->description[sizeof fmt->description - 1] = 0; 687 fmt->description[sizeof fmt->description - 1] = 0;
688 fmt->pixelformat = format->fcc; 688 fmt->pixelformat = format->fcc;