From c0decac19da3906d9b66291e57b7759489e1170f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 10 Sep 2018 08:19:14 -0400 Subject: 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 Reviewed-by: Kees Cook Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-417.c | 2 +- drivers/media/usb/cx231xx/cx231xx-input.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/media/usb/cx231xx') diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index 2f3b0564d676..f700ec35b7f3 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -1583,7 +1583,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strlcpy(f->description, "MPEG", sizeof(f->description)); + strscpy(f->description, "MPEG", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; return 0; diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c index 3e9b73a6b7c9..9f88c640ec2b 100644 --- a/drivers/media/usb/cx231xx/cx231xx-input.c +++ b/drivers/media/usb/cx231xx/cx231xx-input.c @@ -67,7 +67,7 @@ int cx231xx_ir_init(struct cx231xx *dev) dev->init_data.name = cx231xx_boards[dev->model].name; - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); info.platform_data = &dev->init_data; /* diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index f7fcd733a2ca..7759bc66f18c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -1354,22 +1354,22 @@ int cx231xx_g_chip_info(struct file *file, void *fh, case 0: /* Cx231xx - internal registers */ return 0; case 1: /* AFE - read byte */ - strlcpy(chip->name, "AFE (byte)", sizeof(chip->name)); + strscpy(chip->name, "AFE (byte)", sizeof(chip->name)); return 0; case 2: /* Video Block - read byte */ - strlcpy(chip->name, "Video (byte)", sizeof(chip->name)); + strscpy(chip->name, "Video (byte)", sizeof(chip->name)); return 0; case 3: /* I2S block - read byte */ - strlcpy(chip->name, "I2S (byte)", sizeof(chip->name)); + strscpy(chip->name, "I2S (byte)", sizeof(chip->name)); return 0; case 4: /* AFE - read dword */ - strlcpy(chip->name, "AFE (dword)", sizeof(chip->name)); + strscpy(chip->name, "AFE (dword)", sizeof(chip->name)); return 0; case 5: /* Video Block - read dword */ - strlcpy(chip->name, "Video (dword)", sizeof(chip->name)); + strscpy(chip->name, "Video (dword)", sizeof(chip->name)); return 0; case 6: /* I2S Block - read dword */ - strlcpy(chip->name, "I2S (dword)", sizeof(chip->name)); + strscpy(chip->name, "I2S (dword)", sizeof(chip->name)); return 0; } return -EINVAL; @@ -1553,8 +1553,8 @@ int cx231xx_querycap(struct file *file, void *priv, struct cx231xx_fh *fh = priv; struct cx231xx *dev = fh->dev; - strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); - strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); + strscpy(cap->driver, "cx231xx", sizeof(cap->driver)); + strscpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); if (vdev->vfl_type == VFL_TYPE_RADIO) @@ -1583,7 +1583,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (unlikely(f->index >= ARRAY_SIZE(format))) return -EINVAL; - strlcpy(f->description, format[f->index].name, sizeof(f->description)); + strscpy(f->description, format[f->index].name, sizeof(f->description)); f->pixelformat = format[f->index].fourcc; return 0; -- cgit v1.2.3-59-g8ed1b