Skip to content

Commit

Permalink
media: replace strncpy() by strscpy()
Browse files Browse the repository at this point in the history
The strncpy() function is being deprecated upstream. Replace
it by the safer strscpy().

While here, replace a few occurences of strlcpy() that were
recently added to also use strscpy().

Reviewed-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mchehab committed Mar 29, 2019
1 parent 060162c commit 85709cb
Show file tree
Hide file tree
Showing 35 changed files with 70 additions and 68 deletions.
2 changes: 1 addition & 1 deletion drivers/media/dvb-frontends/as102_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ struct dvb_frontend *as102_attach(const char *name,

/* init frontend callback ops */
memcpy(&fe->ops, &as102_fe_ops, sizeof(struct dvb_frontend_ops));
strncpy(fe->ops.info.name, name, sizeof(fe->ops.info.name));
strscpy(fe->ops.info.name, name, sizeof(fe->ops.info.name));

return fe;

Expand Down
3 changes: 2 additions & 1 deletion drivers/media/dvb-frontends/dib7000p.c
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,8 @@ static struct dvb_frontend *dib7000p_init(struct i2c_adapter *i2c_adap, u8 i2c_a
dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr);

/* init 7090 tuner adapter */
strncpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface", sizeof(st->dib7090_tuner_adap.name));
strscpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface",
sizeof(st->dib7090_tuner_adap.name));
st->dib7090_tuner_adap.algo = &dib7090_tuner_xfer_algo;
st->dib7090_tuner_adap.algo_data = NULL;
st->dib7090_tuner_adap.dev.parent = st->i2c_adap->dev.parent;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/dib8000.c
Original file line number Diff line number Diff line change
Expand Up @@ -4458,8 +4458,8 @@ static struct dvb_frontend *dib8000_init(struct i2c_adapter *i2c_adap, u8 i2c_ad
dibx000_init_i2c_master(&state->i2c_master, DIB8000, state->i2c.adap, state->i2c.addr);

/* init 8096p tuner adapter */
strncpy(state->dib8096p_tuner_adap.name, "DiB8096P tuner interface",
sizeof(state->dib8096p_tuner_adap.name));
strscpy(state->dib8096p_tuner_adap.name, "DiB8096P tuner interface",
sizeof(state->dib8096p_tuner_adap.name));
state->dib8096p_tuner_adap.algo = &dib8096p_tuner_xfer_algo;
state->dib8096p_tuner_adap.algo_data = NULL;
state->dib8096p_tuner_adap.dev.parent = state->i2c.adap->dev.parent;
Expand Down
6 changes: 4 additions & 2 deletions drivers/media/dvb-frontends/dib9000.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,15 +2521,17 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
dibx000_init_i2c_master(&st->i2c_master, DIB7000MC, st->i2c.i2c_adap, st->i2c.i2c_addr);

st->tuner_adap.dev.parent = i2c_adap->dev.parent;
strncpy(st->tuner_adap.name, "DIB9000_FW TUNER ACCESS", sizeof(st->tuner_adap.name));
strscpy(st->tuner_adap.name, "DIB9000_FW TUNER ACCESS",
sizeof(st->tuner_adap.name));
st->tuner_adap.algo = &dib9000_tuner_algo;
st->tuner_adap.algo_data = NULL;
i2c_set_adapdata(&st->tuner_adap, st);
if (i2c_add_adapter(&st->tuner_adap) < 0)
goto error;

st->component_bus.dev.parent = i2c_adap->dev.parent;
strncpy(st->component_bus.name, "DIB9000_FW COMPONENT BUS ACCESS", sizeof(st->component_bus.name));
strscpy(st->component_bus.name, "DIB9000_FW COMPONENT BUS ACCESS",
sizeof(st->component_bus.name));
st->component_bus.algo = &dib9000_component_bus_algo;
st->component_bus.algo_data = NULL;
st->component_bus_speed = 340;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb-frontends/dvb-pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops,
sizeof(struct dvb_tuner_ops));

strncpy(fe->ops.tuner_ops.info.name, desc->name,
strscpy(fe->ops.tuner_ops.info.name, desc->name,
sizeof(fe->ops.tuner_ops.info.name));

fe->ops.tuner_ops.info.frequency_min_hz = desc->min;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb-frontends/m88ds3103.c
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ static int m88ds3103_probe(struct i2c_client *client,
/* create dvb_frontend */
memcpy(&dev->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops));
if (dev->chip_id == M88RS6000_CHIP_ID)
strncpy(dev->fe.ops.info.name, "Montage Technology M88RS6000",
strscpy(dev->fe.ops.info.name, "Montage Technology M88RS6000",
sizeof(dev->fe.ops.info.name));
if (!pdata->attach_in_use)
dev->fe.ops.release = NULL;
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/pci/bt8xx/dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ static int dst_get_device_id(struct dst_state *state)
/* Card capabilities */
state->dst_hw_cap = p_dst_type->dst_feature;
pr_err("Recognise [%s]\n", p_dst_type->device_id);
strncpy(&state->fw_name[0], p_dst_type->device_id, 6);
strscpy((char *)state->fw_name, p_dst_type->device_id,
sizeof(state->fw_name));
/* Multiple tuners */
if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) {
switch (use_dst_type) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/mantis/mantis_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int mantis_i2c_init(struct mantis_pci *mantis)

init_waitqueue_head(&mantis->i2c_wq);
mutex_init(&mantis->i2c_lock);
strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
strscpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
i2c_set_adapdata(i2c_adapter, mantis);

i2c_adapter->owner = THIS_MODULE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/saa7134/saa7134-go7007.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
sd = &saa->sd;
v4l2_subdev_init(sd, &saa7134_go7007_sd_ops);
v4l2_set_subdevdata(sd, saa);
strncpy(sd->name, "saa7134-go7007", sizeof(sd->name));
strscpy(sd->name, "saa7134-go7007", sizeof(sd->name));

/* Allocate a couple pages for receiving the compressed stream */
saa->top = (u8 *)get_zeroed_page(GFP_KERNEL);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/am437x/am437x-vpfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ static int vpfe_enum_fmt(struct file *file, void *priv,
if (!fmt)
return -EINVAL;

strncpy(f->description, fmt->name, sizeof(f->description) - 1);
strscpy(f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
f->type = vpfe->fmt.type;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/davinci/vpfe_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ static int vpfe_probe(struct platform_device *pdev)

mutex_lock(&ccdc_lock);

strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
strscpy(ccdc_cfg->name, vpfe_cfg->ccdc, sizeof(ccdc_cfg->name));
/* Get VINT0 irq resource */
res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res1) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/platform/davinci/vpif_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,8 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
} else {
std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
}
strncpy(std_info->name, "Custom timings BT656/1120", VPIF_MAX_NAME);
strscpy(std_info->name, "Custom timings BT656/1120",
sizeof(std_info->name));
std_info->width = bt->width;
std_info->height = bt->height;
std_info->frm_fmt = bt->interlaced ? 0 : 1;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/davinci/vpif_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,8 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
} else {
std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
}
strncpy(std_info->name, "Custom timings BT656/1120",
VPIF_MAX_NAME);
strscpy(std_info->name, "Custom timings BT656/1120",
sizeof(std_info->name));
std_info->width = bt->width;
std_info->height = bt->height;
std_info->frm_fmt = bt->interlaced ? 0 : 1;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/exynos4-is/fimc-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv,
f->index);
if (!fmt)
return -EINVAL;
strncpy(f->description, fmt->name, sizeof(f->description) - 1);
strscpy(f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
if (fmt->fourcc == MEDIA_BUS_FMT_JPEG_1X8)
f->flags |= V4L2_FMT_FLAG_COMPRESSED;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/exynos4-is/fimc-m2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int fimc_m2m_enum_fmt_mplane(struct file *file, void *priv,
if (!fmt)
return -EINVAL;

strncpy(f->description, fmt->name, sizeof(f->description) - 1);
strscpy(f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/imx-pxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ static irqreturn_t pxp_irq_handler(int irq, void *dev_id)
static int pxp_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strlcpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
strlcpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:%s", MEM2MEM_NAME);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/mtk-vpu/mtk_vpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv)
struct vpu_run *run = (struct vpu_run *)data;

vpu->run.signaled = run->signaled;
strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN);
strscpy(vpu->run.fw_ver, run->fw_ver, sizeof(vpu->run.fw_ver));
vpu->run.dec_capability = run->dec_capability;
vpu->run.enc_capability = run->enc_capability;
wake_up_interruptible(&vpu->run.wq);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/mx2_emmaprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1);
strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1);
strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/platform/s5p-g2d/g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ static int g2d_release(struct file *file)
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strncpy(cap->driver, G2D_NAME, sizeof(cap->driver) - 1);
strncpy(cap->card, G2D_NAME, sizeof(cap->card) - 1);
strscpy(cap->driver, G2D_NAME, sizeof(cap->driver));
strscpy(cap->card, G2D_NAME, sizeof(cap->card));
cap->bus_info[0] = 0;
cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
Expand All @@ -312,7 +312,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
return -EINVAL;
fmt = &formats[f->index];
f->pixelformat = fmt->fourcc;
strncpy(f->description, fmt->name, sizeof(f->description) - 1);
strscpy(f->description, fmt->name, sizeof(f->description));
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static int vidioc_enum_input(struct file *file, void *fh,
if (inp->index != 0)
return -EINVAL;

strlcpy(inp->name, "camera", sizeof(inp->name));
strscpy(inp->name, "camera", sizeof(inp->name));
inp->type = V4L2_INPUT_TYPE_CAMERA;

return 0;
Expand Down Expand Up @@ -644,7 +644,7 @@ int sun6i_video_init(struct sun6i_video *video, struct sun6i_csi *csi,
}

/* Register video device */
strlcpy(vdev->name, name, sizeof(vdev->name));
strscpy(vdev->name, name, sizeof(vdev->name));
vdev->release = video_device_release_empty;
vdev->fops = &sun6i_video_fops;
vdev->ioctl_ops = &sun6i_video_ioctl_ops;
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/platform/ti-vpe/vpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,8 +1491,8 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
static int vpe_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strncpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver) - 1);
strncpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card) - 1);
strscpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver));
strscpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
VPE_MODULE_NAME);
cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
Expand All @@ -1519,7 +1519,7 @@ static int __enum_fmt(struct v4l2_fmtdesc *f, u32 type)
if (!fmt)
return -EINVAL;

strncpy(f->description, fmt->name, sizeof(f->description) - 1);
strscpy(f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc;
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/vicodec/vicodec-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ static const struct v4l2_fwht_pixfmt_info *find_fmt(u32 fmt)
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strncpy(cap->driver, VICODEC_NAME, sizeof(cap->driver) - 1);
strncpy(cap->card, VICODEC_NAME, sizeof(cap->card) - 1);
strscpy(cap->driver, VICODEC_NAME, sizeof(cap->driver));
strscpy(cap->card, VICODEC_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:%s", VICODEC_NAME);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/vim2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ static void device_work(struct work_struct *w)
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1);
strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1);
strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:%s", MEM2MEM_NAME);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/vivid/vivid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
dev->v4l2_dev.mdev = &dev->mdev;

/* Initialize media device */
strlcpy(dev->mdev.model, VIVID_MODULE_NAME, sizeof(dev->mdev.model));
strscpy(dev->mdev.model, VIVID_MODULE_NAME, sizeof(dev->mdev.model));
snprintf(dev->mdev.bus_info, sizeof(dev->mdev.bus_info),
"platform:%s-%03d", VIVID_MODULE_NAME, inst);
dev->mdev.dev = &pdev->dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/si4713/si4713.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
if (vm->index > 0)
return -EINVAL;

strncpy(vm->name, "FM Modulator", 32);
strscpy(vm->name, "FM Modulator", sizeof(vm->name));
vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW |
V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_CONTROLS;

Expand Down
16 changes: 8 additions & 8 deletions drivers/media/usb/go7007/go7007-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
usb->usbdev = usbdev;
usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info));
go->board_id = id->driver_info;
strncpy(go->name, name, sizeof(go->name));
strscpy(go->name, name, sizeof(go->name));
if (board->flags & GO7007_USB_EZUSB)
go->hpi_ops = &go7007_usb_ezusb_hpi_ops;
else
Expand Down Expand Up @@ -1198,7 +1198,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
go->board_id = GO7007_BOARDID_ENDURA;
usb->board = board = &board_endura;
go->board_info = &board->main_info;
strncpy(go->name, "Pelco Endura",
strscpy(go->name, "Pelco Endura",
sizeof(go->name));
} else {
u16 channel;
Expand Down Expand Up @@ -1232,21 +1232,21 @@ static int go7007_usb_probe(struct usb_interface *intf,
case 1:
go->tuner_type = TUNER_SONY_BTF_PG472Z;
go->std = V4L2_STD_PAL;
strncpy(go->name, "Plextor PX-TV402U-EU",
sizeof(go->name));
strscpy(go->name, "Plextor PX-TV402U-EU",
sizeof(go->name));
break;
case 2:
go->tuner_type = TUNER_SONY_BTF_PK467Z;
go->std = V4L2_STD_NTSC_M_JP;
num_i2c_devs -= 2;
strncpy(go->name, "Plextor PX-TV402U-JP",
sizeof(go->name));
strscpy(go->name, "Plextor PX-TV402U-JP",
sizeof(go->name));
break;
case 3:
go->tuner_type = TUNER_SONY_BTF_PB463Z;
num_i2c_devs -= 2;
strncpy(go->name, "Plextor PX-TV402U-NA",
sizeof(go->name));
strscpy(go->name, "Plextor PX-TV402U-NA",
sizeof(go->name));
break;
default:
pr_debug("unable to detect tuner type!\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/usb/go7007/go7007-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt->flags = V4L2_FMT_FLAG_COMPRESSED;

strncpy(fmt->description, desc, sizeof(fmt->description));
strscpy(fmt->description, desc, sizeof(fmt->description));

return 0;
}
Expand Down
10 changes: 4 additions & 6 deletions drivers/media/usb/hdpvr/hdpvr-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,7 @@ static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)

i->type = V4L2_INPUT_TYPE_CAMERA;

strncpy(i->name, iname[n], sizeof(i->name) - 1);
i->name[sizeof(i->name) - 1] = '\0';
strscpy(i->name, iname[n], sizeof(i->name));

i->audioset = 1<<HDPVR_RCA_FRONT | 1<<HDPVR_RCA_BACK | 1<<HDPVR_SPDIF;

Expand Down Expand Up @@ -841,8 +840,7 @@ static int vidioc_enumaudio(struct file *file, void *priv,

audio->capability = V4L2_AUDCAP_STEREO;

strncpy(audio->name, audio_iname[n], sizeof(audio->name) - 1);
audio->name[sizeof(audio->name) - 1] = '\0';
strscpy(audio->name, audio_iname[n], sizeof(audio->name));

return 0;
}
Expand Down Expand Up @@ -874,7 +872,6 @@ static int vidioc_g_audio(struct file *file, void *private_data,
audio->index = dev->options.audio_input;
audio->capability = V4L2_AUDCAP_STEREO;
strscpy(audio->name, audio_iname[audio->index], sizeof(audio->name));
audio->name[sizeof(audio->name) - 1] = '\0';
return 0;
}

Expand Down Expand Up @@ -991,7 +988,8 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
return -EINVAL;

f->flags = V4L2_FMT_FLAG_COMPRESSED;
strncpy(f->description, "MPEG2-TS with AVC/AAC streams", 32);
strscpy(f->description, "MPEG2-TS with AVC/AAC streams",
sizeof(f->description));
f->pixelformat = V4L2_PIX_FMT_MPEG;

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/usb/pulse8-cec/pulse8-cec.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 0);
if (err)
return err;
strncpy(log_addrs->osd_name, data, 13);
strscpy(log_addrs->osd_name, data, sizeof(log_addrs->osd_name));
dev_dbg(pulse8->dev, "OSD name: %s\n", log_addrs->osd_name);

return 0;
Expand Down Expand Up @@ -566,7 +566,7 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
char *osd_str = cmd + 1;

cmd[0] = MSGCODE_SET_OSD_NAME;
strncpy(cmd + 1, adap->log_addrs.osd_name, 13);
strscpy(cmd + 1, adap->log_addrs.osd_name, sizeof(cmd) - 1);
if (osd_len < 4) {
memset(osd_str + osd_len, ' ', 4 - osd_len);
osd_len = 4;
Expand Down
Loading

0 comments on commit 85709cb

Please sign in to comment.