diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-10 15:19:14 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-11 20:32:17 +0300 |
commit | c0decac19da3906d9b66291e57b7759489e1170f (patch) | |
tree | 0eeb1f7d2c5464e0c87e0c788fd8fb581662c621 /drivers/media/radio | |
parent | b730c40813a95ebc35757790a990794f55e2b61c (diff) | |
download | linux-c0decac19da3906d9b66291e57b7759489e1170f.tar.xz |
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/radio')
25 files changed, 92 insertions, 90 deletions
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 8521bb2825e8..a6f207b448be 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c @@ -174,8 +174,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct dsbr100_device *radio = video_drvdata(file); - strlcpy(v->driver, "dsbr100", sizeof(v->driver)); - strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof(v->card)); + strscpy(v->driver, "dsbr100", sizeof(v->driver)); + strscpy(v->card, "D-Link R-100 USB FM Radio", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -379,7 +379,8 @@ static int usb_dsbr100_probe(struct usb_interface *intf, goto err_reg_ctrl; } mutex_init(&radio->v4l2_lock); - strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); + strscpy(radio->videodev.name, v4l2_dev->name, + sizeof(radio->videodev.name)); radio->videodev.v4l2_dev = v4l2_dev; radio->videodev.fops = &usb_dsbr100_fops; radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 5b82e63885cd..d12e07e32546 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c @@ -353,9 +353,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { - strlcpy(v->driver, "ADS Cadet", sizeof(v->driver)); - strlcpy(v->card, "ADS Cadet", sizeof(v->card)); - strlcpy(v->bus_info, "ISA:radio-cadet", sizeof(v->bus_info)); + strscpy(v->driver, "ADS Cadet", sizeof(v->driver)); + strscpy(v->card, "ADS Cadet", sizeof(v->card)); + strscpy(v->bus_info, "ISA:radio-cadet", sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -370,7 +370,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index) return -EINVAL; v->type = V4L2_TUNER_RADIO; - strlcpy(v->name, "Radio", sizeof(v->name)); + strscpy(v->name, "Radio", sizeof(v->name)); v->capability = bands[0].capability | bands[1].capability; v->rangelow = bands[0].rangelow; /* 520 kHz (start of AM band) */ v->rangehigh = bands[1].rangehigh; /* 108.0 MHz (end of FM band) */ @@ -595,7 +595,7 @@ static int __init cadet_init(void) struct v4l2_ctrl_handler *hdl; int res = -ENODEV; - strlcpy(v4l2_dev->name, "cadet", sizeof(v4l2_dev->name)); + strscpy(v4l2_dev->name, "cadet", sizeof(v4l2_dev->name)); mutex_init(&dev->lock); /* If a probe was requested then probe ISAPnP first (safest) */ @@ -639,7 +639,7 @@ static int __init cadet_init(void) dev->is_fm_band = true; dev->curfreq = bands[dev->is_fm_band].rangelow; cadet_setfreq(dev, dev->curfreq); - strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name)); + strscpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name)); dev->vdev.v4l2_dev = v4l2_dev; dev->vdev.fops = &cadet_fops; dev->vdev.ioctl_ops = &cadet_ioctl_ops; diff --git a/drivers/media/radio/radio-isa.c b/drivers/media/radio/radio-isa.c index 7312e469e850..551de8a45b95 100644 --- a/drivers/media/radio/radio-isa.c +++ b/drivers/media/radio/radio-isa.c @@ -42,8 +42,8 @@ static int radio_isa_querycap(struct file *file, void *priv, { struct radio_isa_card *isa = video_drvdata(file); - strlcpy(v->driver, isa->drv->driver.driver.name, sizeof(v->driver)); - strlcpy(v->card, isa->drv->card, sizeof(v->card)); + strscpy(v->driver, isa->drv->driver.driver.name, sizeof(v->driver)); + strscpy(v->card, isa->drv->card, sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; @@ -60,7 +60,7 @@ static int radio_isa_g_tuner(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->rangelow = FREQ_LOW; v->rangehigh = FREQ_HIGH; @@ -198,7 +198,7 @@ static struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv, dev_set_drvdata(pdev, isa); isa->drv = drv; v4l2_dev = &isa->v4l2_dev; - strlcpy(v4l2_dev->name, dev_name(pdev), sizeof(v4l2_dev->name)); + strscpy(v4l2_dev->name, dev_name(pdev), sizeof(v4l2_dev->name)); return isa; } @@ -243,7 +243,7 @@ static int radio_isa_common_probe(struct radio_isa_card *isa, mutex_init(&isa->lock); isa->vdev.lock = &isa->lock; - strlcpy(isa->vdev.name, v4l2_dev->name, sizeof(isa->vdev.name)); + strscpy(isa->vdev.name, v4l2_dev->name, sizeof(isa->vdev.name)); isa->vdev.v4l2_dev = v4l2_dev; isa->vdev.fops = &radio_isa_fops; isa->vdev.ioctl_ops = &radio_isa_ioctl_ops; diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c index f2ea8bc5f5ee..e9484b013073 100644 --- a/drivers/media/radio/radio-keene.c +++ b/drivers/media/radio/radio-keene.c @@ -174,8 +174,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct keene_device *radio = video_drvdata(file); - strlcpy(v->driver, "radio-keene", sizeof(v->driver)); - strlcpy(v->card, "Keene FM Transmitter", sizeof(v->card)); + strscpy(v->driver, "radio-keene", sizeof(v->driver)); + strscpy(v->card, "Keene FM Transmitter", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_RADIO | V4L2_CAP_MODULATOR; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -190,7 +190,7 @@ static int vidioc_g_modulator(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->rangelow = FREQ_MIN * FREQ_MUL; v->rangehigh = FREQ_MAX * FREQ_MUL; v->txsubchans = radio->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; @@ -362,7 +362,7 @@ static int usb_keene_probe(struct usb_interface *intf, radio->v4l2_dev.ctrl_handler = hdl; radio->v4l2_dev.release = usb_keene_video_device_release; - strlcpy(radio->vdev.name, radio->v4l2_dev.name, + strscpy(radio->vdev.name, radio->v4l2_dev.name, sizeof(radio->vdev.name)); radio->vdev.v4l2_dev = &radio->v4l2_dev; radio->vdev.fops = &usb_keene_fops; diff --git a/drivers/media/radio/radio-ma901.c b/drivers/media/radio/radio-ma901.c index fdc481257efd..0a59d97d4627 100644 --- a/drivers/media/radio/radio-ma901.c +++ b/drivers/media/radio/radio-ma901.c @@ -197,8 +197,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct ma901radio_device *radio = video_drvdata(file); - strlcpy(v->driver, "radio-ma901", sizeof(v->driver)); - strlcpy(v->card, "Masterkit MA901 USB FM Radio", sizeof(v->card)); + strscpy(v->driver, "radio-ma901", sizeof(v->driver)); + strscpy(v->card, "Masterkit MA901 USB FM Radio", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -400,7 +400,7 @@ static int usb_ma901radio_probe(struct usb_interface *intf, radio->v4l2_dev.ctrl_handler = &radio->hdl; radio->v4l2_dev.release = usb_ma901radio_release; - strlcpy(radio->vdev.name, radio->v4l2_dev.name, + strscpy(radio->vdev.name, radio->v4l2_dev.name, sizeof(radio->vdev.name)); radio->vdev.v4l2_dev = &radio->v4l2_dev; radio->vdev.fops = &usb_ma901radio_fops; diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index e4e758739246..1b97ad2ce7d0 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c @@ -142,7 +142,7 @@ static int maxiradio_probe(struct pci_dev *pdev, dev->tea.cannot_read_data = true; dev->tea.v4l2_dev = v4l2_dev; dev->tea.radio_nr = radio_nr; - strlcpy(dev->tea.card, "Maxi Radio FM2000", sizeof(dev->tea.card)); + strscpy(dev->tea.card, "Maxi Radio FM2000", sizeof(dev->tea.card)); snprintf(dev->tea.bus_info, sizeof(dev->tea.bus_info), "PCI:%s", pci_name(pdev)); diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c index 7b35e633118d..b626567b75c5 100644 --- a/drivers/media/radio/radio-miropcm20.c +++ b/drivers/media/radio/radio-miropcm20.c @@ -200,8 +200,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct pcm20 *dev = video_drvdata(file); - strlcpy(v->driver, "Miro PCM20", sizeof(v->driver)); - strlcpy(v->card, "Miro PCM20", sizeof(v->card)); + strscpy(v->driver, "Miro PCM20", sizeof(v->driver)); + strscpy(v->card, "Miro PCM20", sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", dev->v4l2_dev.name); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -231,7 +231,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index) return -EINVAL; - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->rangelow = 87*16000; v->rangehigh = 108*16000; @@ -443,7 +443,7 @@ static int __init pcm20_init(void) "you must load the snd-miro driver first!\n"); return -ENODEV; } - strlcpy(v4l2_dev->name, "radio-miropcm20", sizeof(v4l2_dev->name)); + strscpy(v4l2_dev->name, "radio-miropcm20", sizeof(v4l2_dev->name)); mutex_init(&dev->lock); res = v4l2_device_register(NULL, v4l2_dev); @@ -474,7 +474,7 @@ static int __init pcm20_init(void) v4l2_err(v4l2_dev, "Could not register control\n"); goto err_hdl; } - strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name)); + strscpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name)); dev->vdev.v4l2_dev = v4l2_dev; dev->vdev.fops = &pcm20_fops; dev->vdev.ioctl_ops = &pcm20_ioctl_ops; diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 0f292c6ba338..e7c35b184e21 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -266,8 +266,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct amradio_device *radio = video_drvdata(file); - strlcpy(v->driver, "radio-mr800", sizeof(v->driver)); - strlcpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); + strscpy(v->driver, "radio-mr800", sizeof(v->driver)); + strscpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER | V4L2_CAP_HW_FREQ_SEEK; @@ -547,7 +547,7 @@ static int usb_amradio_probe(struct usb_interface *intf, radio->v4l2_dev.ctrl_handler = &radio->hdl; radio->v4l2_dev.release = usb_amradio_release; - strlcpy(radio->vdev.name, radio->v4l2_dev.name, + strscpy(radio->vdev.name, radio->v4l2_dev.name, sizeof(radio->vdev.name)); radio->vdev.v4l2_dev = &radio->v4l2_dev; radio->vdev.fops = &usb_amradio_fops; diff --git a/drivers/media/radio/radio-raremono.c b/drivers/media/radio/radio-raremono.c index 9a5079d64c4a..5e782b3c2fa9 100644 --- a/drivers/media/radio/radio-raremono.c +++ b/drivers/media/radio/radio-raremono.c @@ -181,8 +181,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct raremono_device *radio = video_drvdata(file); - strlcpy(v->driver, "radio-raremono", sizeof(v->driver)); - strlcpy(v->card, "Thanko's Raremono", sizeof(v->card)); + strscpy(v->driver, "radio-raremono", sizeof(v->driver)); + strscpy(v->card, "Thanko's Raremono", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -212,7 +212,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - strlcpy(v->name, "AM/FM/SW", sizeof(v->name)); + strscpy(v->name, "AM/FM/SW", sizeof(v->name)); v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_FREQ_BANDS; v->rangelow = AM_FREQ_RANGE_LOW * 16; @@ -338,7 +338,7 @@ static int usb_raremono_probe(struct usb_interface *intf, mutex_init(&radio->lock); - strlcpy(radio->vdev.name, radio->v4l2_dev.name, + strscpy(radio->vdev.name, radio->v4l2_dev.name, sizeof(radio->vdev.name)); radio->vdev.v4l2_dev = &radio->v4l2_dev; radio->vdev.fops = &usb_raremono_fops; diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 4f9b97edd9eb..a8fedc963614 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -129,9 +129,9 @@ static void fmi_set_freq(struct fmi *fmi) static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { - strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver)); - strlcpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card)); - strlcpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info)); + strscpy(v->driver, "radio-sf16fmi", sizeof(v->driver)); + strscpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card)); + strscpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; @@ -145,7 +145,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->rangelow = RSF16_MINFREQ; v->rangehigh = RSF16_MAXFREQ; @@ -315,7 +315,7 @@ static int __init fmi_init(void) return -ENODEV; } - strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name)); + strscpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name)); fmi->io = io; res = v4l2_device_register(NULL, v4l2_dev); @@ -339,7 +339,7 @@ static int __init fmi_init(void) return res; } - strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); + strscpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); fmi->vdev.v4l2_dev = v4l2_dev; fmi->vdev.fops = &fmi_fops; fmi->vdev.ioctl_ops = &fmi_ioctl_ops; diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index 7b07d42a9909..ca8a1c263eac 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c @@ -213,8 +213,8 @@ static int fmr2_probe(struct fmr2 *fmr2, struct device *pdev, int io) if (io == fmr2_cards[i]->io) return -EBUSY; - strlcpy(fmr2->v4l2_dev.name, "radio-sf16fmr2", - sizeof(fmr2->v4l2_dev.name)), + strscpy(fmr2->v4l2_dev.name, "radio-sf16fmr2", + sizeof(fmr2->v4l2_dev.name)), fmr2->io = io; if (!request_region(fmr2->io, 2, fmr2->v4l2_dev.name)) { @@ -234,7 +234,7 @@ static int fmr2_probe(struct fmr2 *fmr2, struct device *pdev, int io) fmr2->tea.radio_nr = radio_nr[num_fmr2_cards]; fmr2->tea.ops = &fmr2_tea_ops; fmr2->tea.ext_init = fmr2_tea_ext_init; - strlcpy(fmr2->tea.card, card_name, sizeof(fmr2->tea.card)); + strscpy(fmr2->tea.card, card_name, sizeof(fmr2->tea.card)); snprintf(fmr2->tea.bus_info, sizeof(fmr2->tea.bus_info), "%s:%s", fmr2->is_fmd2 ? "PnP" : "ISA", dev_name(pdev)); diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c index 22f3466af2b1..8230da828d0e 100644 --- a/drivers/media/radio/radio-shark.c +++ b/drivers/media/radio/radio-shark.c @@ -345,7 +345,7 @@ static int usb_shark_probe(struct usb_interface *intf, shark->tea.ops = &shark_tea_ops; shark->tea.cannot_mute = true; shark->tea.has_am = true; - strlcpy(shark->tea.card, "Griffin radioSHARK", + strscpy(shark->tea.card, "Griffin radioSHARK", sizeof(shark->tea.card)); usb_make_path(shark->usbdev, shark->tea.bus_info, sizeof(shark->tea.bus_info)); diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c index 4d1a4b3d669c..d150f12382c6 100644 --- a/drivers/media/radio/radio-shark2.c +++ b/drivers/media/radio/radio-shark2.c @@ -310,7 +310,7 @@ static int usb_shark_probe(struct usb_interface *intf, shark->tea.ops = &shark_tea_ops; shark->tea.has_am = true; shark->tea.write_before_read = true; - strlcpy(shark->tea.card, "Griffin radioSHARK2", + strscpy(shark->tea.card, "Griffin radioSHARK2", sizeof(shark->tea.card)); usb_make_path(shark->usbdev, shark->tea.bus_info, sizeof(shark->tea.bus_info)); diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c index b52e678c6901..269971145f88 100644 --- a/drivers/media/radio/radio-si476x.c +++ b/drivers/media/radio/radio-si476x.c @@ -340,9 +340,9 @@ static int si476x_radio_querycap(struct file *file, void *priv, { struct si476x_radio *radio = video_drvdata(file); - strlcpy(capability->driver, radio->v4l2dev.name, + strscpy(capability->driver, radio->v4l2dev.name, sizeof(capability->driver)); - strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); + strscpy(capability->card, DRIVER_CARD, sizeof(capability->card)); snprintf(capability->bus_info, sizeof(capability->bus_info), "platform:%s", radio->v4l2dev.name); @@ -428,15 +428,15 @@ static int si476x_radio_g_tuner(struct file *file, void *priv, si476x_core_lock(radio->core); if (si476x_core_is_a_secondary_tuner(radio->core)) { - strlcpy(tuner->name, "FM (secondary)", sizeof(tuner->name)); + strscpy(tuner->name, "FM (secondary)", sizeof(tuner->name)); tuner->rxsubchans = 0; tuner->rangelow = si476x_bands[SI476X_BAND_FM].rangelow; } else if (si476x_core_has_am(radio->core)) { if (si476x_core_is_a_primary_tuner(radio->core)) - strlcpy(tuner->name, "AM/FM (primary)", + strscpy(tuner->name, "AM/FM (primary)", sizeof(tuner->name)); else - strlcpy(tuner->name, "AM/FM", sizeof(tuner->name)); + strscpy(tuner->name, "AM/FM", sizeof(tuner->name)); tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_RDS; @@ -446,7 +446,7 @@ static int si476x_radio_g_tuner(struct file *file, void *priv, tuner->rangelow = si476x_bands[SI476X_BAND_AM].rangelow; } else { - strlcpy(tuner->name, "FM", sizeof(tuner->name)); + strscpy(tuner->name, "FM", sizeof(tuner->name)); tuner->rxsubchans = V4L2_TUNER_SUB_RDS; tuner->capability |= V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index afb763256fd6..6632be648cea 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -287,8 +287,8 @@ static int vidioc_querycap(struct file *file, void *priv, struct tea5764_device *radio = video_drvdata(file); struct video_device *dev = &radio->vdev; - strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); - strlcpy(v->card, dev->name, sizeof(v->card)); + strscpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); + strscpy(v->card, dev->name, sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev_name(&dev->dev)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; @@ -305,7 +305,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; tea5764_i2c_read(radio); v->rangelow = FREQ_MIN * FREQ_MUL; diff --git a/drivers/media/radio/radio-tea5777.c b/drivers/media/radio/radio-tea5777.c index 04ed1a5d1177..61f751cf1aa4 100644 --- a/drivers/media/radio/radio-tea5777.c +++ b/drivers/media/radio/radio-tea5777.c @@ -266,10 +266,10 @@ static int vidioc_querycap(struct file *file, void *priv, { struct radio_tea5777 *tea = video_drvdata(file); - strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); - strlcpy(v->card, tea->card, sizeof(v->card)); + strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); + strscpy(v->card, tea->card, sizeof(v->card)); strlcat(v->card, " TEA5777", sizeof(v->card)); - strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); + strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; v->device_caps |= V4L2_CAP_HW_FREQ_SEEK; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -304,9 +304,9 @@ static int vidioc_g_tuner(struct file *file, void *priv, memset(v, 0, sizeof(*v)); if (tea->has_am) - strlcpy(v->name, "AM/FM", sizeof(v->name)); + strscpy(v->name, "AM/FM", sizeof(v->name)); else - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_FREQ_BANDS | @@ -560,7 +560,7 @@ int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner) tea->vd = tea575x_radio; video_set_drvdata(&tea->vd, tea); mutex_init(&tea->mutex); - strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); + strscpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); tea->vd.lock = &tea->mutex; tea->vd.v4l2_dev = tea->v4l2_dev; tea->fops = tea575x_fops; diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index fc4d9a73ab17..0eda863124e9 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -39,8 +39,8 @@ struct timbradio { static int timbradio_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { - strlcpy(v->driver, DRIVER_NAME, sizeof(v->driver)); - strlcpy(v->card, "Timberdale Radio", sizeof(v->card)); + strscpy(v->driver, DRIVER_NAME, sizeof(v->driver)); + strscpy(v->card, "Timberdale Radio", sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "platform:"DRIVER_NAME); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -115,7 +115,7 @@ static int timbradio_probe(struct platform_device *pdev) tr->pdata = *pdata; mutex_init(&tr->lock); - strlcpy(tr->video_dev.name, "Timberdale Radio", + strscpy(tr->video_dev.name, "Timberdale Radio", sizeof(tr->video_dev.name)); tr->video_dev.fops = &timbradio_fops; tr->video_dev.ioctl_ops = &timbradio_ioctl_ops; @@ -123,7 +123,7 @@ static int timbradio_probe(struct platform_device *pdev) tr->video_dev.minor = -1; tr->video_dev.lock = &tr->lock; - strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name)); + strscpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name)); err = v4l2_device_register(NULL, &tr->v4l2_dev); if (err) goto err; diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index 11aa94f189cb..b95704f3cb8b 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c @@ -1286,11 +1286,11 @@ static int wl1273_fm_vidioc_querycap(struct file *file, void *priv, dev_dbg(radio->dev, "%s\n", __func__); - strlcpy(capability->driver, WL1273_FM_DRIVER_NAME, + strscpy(capability->driver, WL1273_FM_DRIVER_NAME, sizeof(capability->driver)); - strlcpy(capability->card, "Texas Instruments Wl1273 FM Radio", + strscpy(capability->card, "Texas Instruments Wl1273 FM Radio", sizeof(capability->card)); - strlcpy(capability->bus_info, radio->bus_type, + strscpy(capability->bus_info, radio->bus_type, sizeof(capability->bus_info)); capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | @@ -1488,7 +1488,7 @@ static int wl1273_fm_vidioc_g_audio(struct file *file, void *priv, if (audio->index > 1) return -EINVAL; - strlcpy(audio->name, "Radio", sizeof(audio->name)); + strscpy(audio->name, "Radio", sizeof(audio->name)); audio->capability = V4L2_AUDCAP_STEREO; return 0; @@ -1523,7 +1523,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, if (tuner->index > 0) return -EINVAL; - strlcpy(tuner->name, WL1273_FM_DRIVER_NAME, sizeof(tuner->name)); + strscpy(tuner->name, WL1273_FM_DRIVER_NAME, sizeof(tuner->name)); tuner->type = V4L2_TUNER_RADIO; tuner->rangelow = WL1273_FREQ(WL1273_BAND_JAPAN_LOW); @@ -1781,7 +1781,7 @@ static int wl1273_fm_vidioc_g_modulator(struct file *file, void *priv, dev_dbg(radio->dev, "%s\n", __func__); - strlcpy(modulator->name, WL1273_FM_DRIVER_NAME, + strscpy(modulator->name, WL1273_FM_DRIVER_NAME, sizeof(modulator->name)); modulator->rangelow = WL1273_FREQ(WL1273_BAND_JAPAN_LOW); diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c index e3b3ecd14a4d..9751ea1d80be 100644 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c @@ -229,8 +229,8 @@ static int si470x_fops_release(struct file *file) static int si470x_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *capability) { - strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); - strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); + strscpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); + strscpy(capability->card, DRIVER_CARD, sizeof(capability->card)); capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_READWRITE | V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE; capability->capabilities = capability->device_caps | V4L2_CAP_DEVICE_CAPS; diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c index 313a95f195a2..91d6ef5579f7 100644 --- a/drivers/media/radio/si470x/radio-si470x-usb.c +++ b/drivers/media/radio/si470x/radio-si470x-usb.c @@ -519,8 +519,8 @@ static int si470x_vidioc_querycap(struct file *file, void *priv, { struct si470x_device *radio = video_drvdata(file); - strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); - strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); + strscpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); + strscpy(capability->card, DRIVER_CARD, sizeof(capability->card)); usb_make_path(radio->usbdev, capability->bus_info, sizeof(capability->bus_info)); capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_READWRITE | diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c index 27339ec495f6..733fcf3933e4 100644 --- a/drivers/media/radio/si4713/radio-platform-si4713.c +++ b/drivers/media/radio/si4713/radio-platform-si4713.c @@ -67,10 +67,10 @@ static const struct v4l2_file_operations radio_si4713_fops = { static int radio_si4713_querycap(struct file *file, void *priv, struct v4l2_capability *capability) { - strlcpy(capability->driver, "radio-si4713", sizeof(capability->driver)); - strlcpy(capability->card, "Silicon Labs Si4713 Modulator", + strscpy(capability->driver, "radio-si4713", sizeof(capability->driver)); + strscpy(capability->card, "Silicon Labs Si4713 Modulator", sizeof(capability->card)); - strlcpy(capability->bus_info, "platform:radio-si4713", + strscpy(capability->bus_info, "platform:radio-si4713", sizeof(capability->bus_info)); capability->device_caps = V4L2_CAP_MODULATOR | V4L2_CAP_RDS_OUTPUT; capability->capabilities = capability->device_caps | V4L2_CAP_DEVICE_CAPS; diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c b/drivers/media/radio/si4713/radio-usb-si4713.c index 1ebbf0217142..23065ecce979 100644 --- a/drivers/media/radio/si4713/radio-usb-si4713.c +++ b/drivers/media/radio/si4713/radio-usb-si4713.c @@ -67,8 +67,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct si4713_usb_device *radio = video_drvdata(file); - strlcpy(v->driver, "radio-usb-si4713", sizeof(v->driver)); - strlcpy(v->card, "Si4713 FM Transmitter", sizeof(v->card)); + strscpy(v->driver, "radio-usb-si4713", sizeof(v->driver)); + strscpy(v->card, "Si4713 FM Transmitter", sizeof(v->card)); usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_MODULATOR | V4L2_CAP_RDS_OUTPUT; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; @@ -467,7 +467,7 @@ static int usb_si4713_probe(struct usb_interface *intf, radio->vdev.ctrl_handler = sd->ctrl_handler; radio->v4l2_dev.release = usb_si4713_video_device_release; - strlcpy(radio->vdev.name, radio->v4l2_dev.name, + strscpy(radio->vdev.name, radio->v4l2_dev.name, sizeof(radio->vdev.name)); radio->vdev.v4l2_dev = &radio->v4l2_dev; radio->vdev.fops = &usb_si4713_fops; diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c index 7412fe1b10c6..f89f83e04741 100644 --- a/drivers/media/radio/tea575x.c +++ b/drivers/media/radio/tea575x.c @@ -233,10 +233,10 @@ static int vidioc_querycap(struct file *file, void *priv, { struct snd_tea575x *tea = video_drvdata(file); - strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); - strlcpy(v->card, tea->card, sizeof(v->card)); + strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); + strscpy(v->card, tea->card, sizeof(v->card)); strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); - strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); + strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; if (!tea->cannot_read_data) v->device_caps |= V4L2_CAP_HW_FREQ_SEEK; @@ -296,7 +296,7 @@ int snd_tea575x_g_tuner(struct snd_tea575x *tea, struct v4l2_tuner *v) snd_tea575x_enum_freq_bands(tea, &band_fm); memset(v, 0, sizeof(*v)); - strlcpy(v->name, tea->has_am ? "FM/AM" : "FM", sizeof(v->name)); + strscpy(v->name, tea->has_am ? "FM/AM" : "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->capability = band_fm.capability; v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : band_fm.rangelow; @@ -537,7 +537,7 @@ int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner) tea->vd = tea575x_radio; video_set_drvdata(&tea->vd, tea); mutex_init(&tea->mutex); - strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); + strscpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); tea->vd.lock = &tea->mutex; tea->vd.v4l2_dev = tea->v4l2_dev; tea->fops = tea575x_fops; diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c index ed210f4c476a..a76ff2978dfb 100644 --- a/drivers/media/radio/tef6862.c +++ b/drivers/media/radio/tef6862.c @@ -79,7 +79,7 @@ static int tef6862_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *v) return -EINVAL; /* only support FM for now */ - strlcpy(v->name, "FM", sizeof(v->name)); + strscpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; v->rangelow = TEF6862_LO_FREQ; v->rangehigh = TEF6862_HI_FREQ; diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index dccdf6558e6a..c5f433b24713 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c @@ -190,9 +190,9 @@ release_unlock: static int fm_v4l2_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *capability) { - strlcpy(capability->driver, FM_DRV_NAME, sizeof(capability->driver)); - strlcpy(capability->card, FM_DRV_CARD_SHORT_NAME, - sizeof(capability->card)); + strscpy(capability->driver, FM_DRV_NAME, sizeof(capability->driver)); + strscpy(capability->card, FM_DRV_CARD_SHORT_NAME, + sizeof(capability->card)); sprintf(capability->bus_info, "UART"); capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_MODULATOR | @@ -531,7 +531,8 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr) struct v4l2_ctrl *ctrl; int ret; - strlcpy(fmdev->v4l2_dev.name, FM_DRV_NAME, sizeof(fmdev->v4l2_dev.name)); + strscpy(fmdev->v4l2_dev.name, FM_DRV_NAME, + sizeof(fmdev->v4l2_dev.name)); ret = v4l2_device_register(NULL, &fmdev->v4l2_dev); if (ret < 0) return ret; |