Skip to content

Replaces strlcpy with strscpy #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions v4l2loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#define VFL_TYPE_VIDEO VFL_TYPE_GRABBER
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#define strscpy strlcpy
#endif

#define V4L2LOOPBACK_VERSION_CODE \
KERNEL_VERSION(V4L2LOOPBACK_VERSION_MAJOR, V4L2LOOPBACK_VERSION_MINOR, \
V4L2LOOPBACK_VERSION_BUGFIX)
Expand Down Expand Up @@ -901,7 +905,7 @@ static int vidioc_querycap(struct file *file, void *priv,
->device_nr;
__u32 capabilities = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;

strlcpy(cap->driver, "v4l2 loopback", sizeof(cap->driver));
strscpy(cap->driver, "v4l2 loopback", sizeof(cap->driver));
snprintf(cap->card, sizeof(cap->card), "%s", dev->card_label);
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:v4l2loopback-%03d", device_nr);
Expand Down Expand Up @@ -1423,7 +1427,7 @@ static int vidioc_enum_output(struct file *file, void *fh,
memset(outp, 0, sizeof(*outp));

outp->index = index;
strlcpy(outp->name, "loopback in", sizeof(outp->name));
strscpy(outp->name, "loopback in", sizeof(outp->name));
outp->type = V4L2_OUTPUT_TYPE_ANALOG;
outp->audioset = 0;
outp->modulator = 0;
Expand Down Expand Up @@ -1483,7 +1487,7 @@ static int vidioc_enum_input(struct file *file, void *fh,
memset(inp, 0, sizeof(*inp));

inp->index = index;
strlcpy(inp->name, "loopback", sizeof(inp->name));
strscpy(inp->name, "loopback", sizeof(inp->name));
inp->type = V4L2_INPUT_TYPE_CAMERA;
inp->audioset = 0;
inp->tuner = 0;
Expand Down