Commit 48b532b9 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: use strscpy() instead of less secure variants

Replace usages of strcpy(), strlcpy() and strncpy() in favor
of strscpy().
Suggested-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent baf768cf
......@@ -219,7 +219,7 @@ int atomisp_file_input_init(struct atomisp_device *isp)
v4l2_subdev_init(sd, &file_input_ops);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
strcpy(sd->name, "file_input_subdev");
strscpy(sd->name, "file_input_subdev", sizeof(sd->name));
v4l2_set_subdevdata(sd, file_dev);
pads[0].flags = MEDIA_PAD_FL_SINK;
......
......@@ -936,7 +936,7 @@ static int gmin_get_hardcoded_var(struct gmin_cfg_var *varlist,
if (vl > *out_len - 1)
return -ENOSPC;
strcpy(out, gv->val);
strscpy(out, gv->val, *out_len);
*out_len = vl;
return 0;
}
......
......@@ -547,8 +547,8 @@ static int atomisp_querycap(struct file *file, void *fh,
struct video_device *vdev = video_devdata(file);
struct atomisp_device *isp = video_get_drvdata(vdev);
strscpy(cap->driver, DRIVER, sizeof(cap->driver) - 1);
strscpy(cap->card, CARD, sizeof(cap->card) - 1);
strscpy(cap->driver, DRIVER, sizeof(cap->driver));
strscpy(cap->card, CARD, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
pci_name(isp->pdev));
......@@ -573,8 +573,8 @@ static int atomisp_enum_input(struct file *file, void *fh,
return -EINVAL;
memset(input, 0, sizeof(struct v4l2_input));
strncpy(input->name, isp->inputs[index].camera->name,
sizeof(input->name) - 1);
strscpy(input->name, isp->inputs[index].camera->name,
sizeof(input->name));
/*
* HACK: append actuator's name to sensor's
......@@ -593,8 +593,8 @@ static int atomisp_enum_input(struct file *file, void *fh,
if (max_size > 1) {
input->name[cur_len] = '+';
strncpy(&input->name[cur_len + 1],
motor->name, max_size - 1);
strscpy(&input->name[cur_len + 1],
motor->name, max_size);
}
}
......
......@@ -148,7 +148,7 @@ int atomisp_tpg_init(struct atomisp_device *isp)
tpg->isp = isp;
v4l2_subdev_init(sd, &tpg_ops);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
strcpy(sd->name, "tpg_subdev");
strscpy(sd->name, "tpg_subdev", sizeof(sd->name));
v4l2_set_subdevdata(sd, tpg);
pads[0].flags = MEDIA_PAD_FL_SINK;
......
......@@ -44,7 +44,7 @@ TRACE_EVENT(camera_meminfo,
),
TP_fast_assign(
strlcpy(__entry->name, name, 24);
strscpy(__entry->name, name, 24);
__entry->uptr_size = uptr_size;
__entry->counter = counter;
__entry->sys_size = sys_size;
......@@ -74,8 +74,8 @@ TRACE_EVENT(camera_debug,
),
TP_fast_assign(
strlcpy(__entry->name, name, 24);
strlcpy(__entry->info, info, 24);
strscpy(__entry->name, name, 24);
strscpy(__entry->info, info, 24);
__entry->line = line;
),
......
......@@ -1206,7 +1206,7 @@ static int atomisp_register_entities(struct atomisp_device *isp)
isp->media_dev.dev = isp->dev;
strlcpy(isp->media_dev.model, "Intel Atom ISP",
strscpy(isp->media_dev.model, "Intel Atom ISP",
sizeof(isp->media_dev.model));
media_device_init(&isp->media_dev);
......
......@@ -991,8 +991,7 @@ sh_css_sp_init_stage(struct ia_css_binary *binary,
/* Make sure binary name is smaller than allowed string size */
assert(strlen(binary_name) < SH_CSS_MAX_BINARY_NAME - 1);
strncpy(sh_css_isp_stage.binary_name, binary_name, SH_CSS_MAX_BINARY_NAME - 1);
sh_css_isp_stage.binary_name[SH_CSS_MAX_BINARY_NAME - 1] = 0;
strscpy(sh_css_isp_stage.binary_name, binary_name, SH_CSS_MAX_BINARY_NAME);
sh_css_isp_stage.mem_initializers = *isp_mem_if;
/*
......
......@@ -31,7 +31,7 @@ ia_css_get_version(char *version, int max_size) {
if (max_size <= (int)strlen(css_version) + (int)strlen(sh_css_get_fw_version()) + 5)
return -EINVAL;
strcpy(version, css_version);
strscpy(version, css_version, max_size);
strcat(version, "FW:");
strcat(version, sh_css_get_fw_version());
strcat(version, "; ");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment