diff options
author | Laurent Pinchart <laurent.pinchart@skynet.be> | 2009-01-08 14:05:11 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 12:42:26 -0300 |
commit | d0ebf3073f8812464c9f6014d6cee09ab37c3fb5 (patch) | |
tree | cae1337ef45a319301a668c7cf16918283e6dbb4 /drivers/media/video/uvc/uvc_driver.c | |
parent | 07f7db4ce7b29d431553b426e0dcb720c5297a4b (diff) | |
download | linux-d0ebf3073f8812464c9f6014d6cee09ab37c3fb5.tar.gz linux-d0ebf3073f8812464c9f6014d6cee09ab37c3fb5.tar.bz2 linux-d0ebf3073f8812464c9f6014d6cee09ab37c3fb5.zip |
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/uvc_driver.c')
-rw-r--r-- | drivers/media/video/uvc/uvc_driver.c | 16 |
1 files changed, 8 insertions, 8 deletions
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, fmtdesc = uvc_format_by_guid(&buffer[5]); if (fmtdesc != NULL) { - strncpy(format->name, fmtdesc->name, + strlcpy(format->name, fmtdesc->name, sizeof format->name); format->fcc = fmtdesc->fcc; } else { @@ -345,7 +345,7 @@ static int uvc_parse_format(struct uvc_device *dev, return -EINVAL; } - strncpy(format->name, "MJPEG", sizeof format->name); + strlcpy(format->name, "MJPEG", sizeof format->name); format->fcc = V4L2_PIX_FMT_MJPEG; format->flags = UVC_FMT_FLAG_COMPRESSED; format->bpp = 0; @@ -363,13 +363,13 @@ static int uvc_parse_format(struct uvc_device *dev, switch (buffer[8] & 0x7f) { case 0: - strncpy(format->name, "SD-DV", sizeof format->name); + strlcpy(format->name, "SD-DV", sizeof format->name); break; case 1: - strncpy(format->name, "SDL-DV", sizeof format->name); + strlcpy(format->name, "SDL-DV", sizeof format->name); break; case 2: - strncpy(format->name, "HD-DV", sizeof format->name); + strlcpy(format->name, "HD-DV", sizeof format->name); break; default: uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" @@ -379,7 +379,7 @@ static int uvc_parse_format(struct uvc_device *dev, return -EINVAL; } - strncat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz", + strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz", sizeof format->name); format->fcc = V4L2_PIX_FMT_DV; @@ -1526,7 +1526,7 @@ static int uvc_register_video(struct uvc_device *dev) vdev->minor = -1; vdev->fops = &uvc_fops; vdev->release = video_device_release; - strncpy(vdev->name, dev->name, sizeof vdev->name); + strlcpy(vdev->name, dev->name, sizeof vdev->name); /* Set the driver data before calling video_register_device, otherwise * uvc_v4l2_open might race us. @@ -1621,7 +1621,7 @@ static int uvc_probe(struct usb_interface *intf, dev->quirks = id->driver_info | uvc_quirks_param; if (udev->product != NULL) - strncpy(dev->name, udev->product, sizeof dev->name); + strlcpy(dev->name, udev->product, sizeof dev->name); else snprintf(dev->name, sizeof dev->name, "UVC Camera (%04x:%04x)", |