diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-10 08:19:14 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-11 13:32:17 -0400 |
commit | c0decac19da3906d9b66291e57b7759489e1170f (patch) | |
tree | 0eeb1f7d2c5464e0c87e0c788fd8fb581662c621 /drivers/media/usb/pwc/pwc-v4l.c | |
parent | b730c40813a95ebc35757790a990794f55e2b61c (diff) |
media: use strscpy() instead of strlcpy()
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/usb/pwc/pwc-v4l.c')
-rw-r--r-- | drivers/media/usb/pwc/pwc-v4l.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/usb/pwc/pwc-v4l.c b/drivers/media/usb/pwc/pwc-v4l.c index 043b2b97cee6..0673238c2c63 100644 --- a/drivers/media/usb/pwc/pwc-v4l.c +++ b/drivers/media/usb/pwc/pwc-v4l.c | |||
@@ -493,7 +493,7 @@ static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap | |||
493 | struct pwc_device *pdev = video_drvdata(file); | 493 | struct pwc_device *pdev = video_drvdata(file); |
494 | 494 | ||
495 | strcpy(cap->driver, PWC_NAME); | 495 | strcpy(cap->driver, PWC_NAME); |
496 | strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card)); | 496 | strscpy(cap->card, pdev->vdev.name, sizeof(cap->card)); |
497 | usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); | 497 | usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); |
498 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | | 498 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | |
499 | V4L2_CAP_READWRITE; | 499 | V4L2_CAP_READWRITE; |
@@ -506,7 +506,7 @@ static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i) | |||
506 | if (i->index) /* Only one INPUT is supported */ | 506 | if (i->index) /* Only one INPUT is supported */ |
507 | return -EINVAL; | 507 | return -EINVAL; |
508 | 508 | ||
509 | strlcpy(i->name, "Camera", sizeof(i->name)); | 509 | strscpy(i->name, "Camera", sizeof(i->name)); |
510 | i->type = V4L2_INPUT_TYPE_CAMERA; | 510 | i->type = V4L2_INPUT_TYPE_CAMERA; |
511 | return 0; | 511 | return 0; |
512 | } | 512 | } |
@@ -889,11 +889,13 @@ static int pwc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc | |||
889 | /* RAW format */ | 889 | /* RAW format */ |
890 | f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2; | 890 | f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2; |
891 | f->flags = V4L2_FMT_FLAG_COMPRESSED; | 891 | f->flags = V4L2_FMT_FLAG_COMPRESSED; |
892 | strlcpy(f->description, "Raw Philips Webcam", sizeof(f->description)); | 892 | strscpy(f->description, "Raw Philips Webcam", |
893 | sizeof(f->description)); | ||
893 | break; | 894 | break; |
894 | case 1: | 895 | case 1: |
895 | f->pixelformat = V4L2_PIX_FMT_YUV420; | 896 | f->pixelformat = V4L2_PIX_FMT_YUV420; |
896 | strlcpy(f->description, "4:2:0, planar, Y-Cb-Cr", sizeof(f->description)); | 897 | strscpy(f->description, "4:2:0, planar, Y-Cb-Cr", |
898 | sizeof(f->description)); | ||
897 | break; | 899 | break; |
898 | default: | 900 | default: |
899 | return -EINVAL; | 901 | return -EINVAL; |