Skip to content

Commit

Permalink
video: fbdev: uvesafb: Fix string related warnings
Browse files Browse the repository at this point in the history
Two W=1 string related warnings.
- Using strncpy to copy string without null-termination generates a
  warning.  Use memcpy to copy only the relevant chars

- Fix a potential bug with a very long string, subtract one from the
  length to make room for the termination null.

Signed-off-by: Sam Ravnborg <[email protected]>
Acked-by: Thomas Zimmermann <[email protected]>
Cc: Michal Januszewski <[email protected]>
Cc: [email protected]
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
sravnborg committed Dec 5, 2020
1 parent ab2b29e commit 5a15468
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/video/fbdev/uvesafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static int uvesafb_vbe_getinfo(struct uvesafb_ktask *task,
task->t.flags = TF_VBEIB;
task->t.buf_len = sizeof(struct vbe_ib);
task->buf = &par->vbe_ib;
strncpy(par->vbe_ib.vbe_signature, "VBE2", 4);
memcpy(par->vbe_ib.vbe_signature, "VBE2", 4);

err = uvesafb_exec(task);
if (err || (task->t.regs.eax & 0xffff) != 0x004f) {
Expand Down Expand Up @@ -1871,7 +1871,7 @@ static ssize_t v86d_show(struct device_driver *dev, char *buf)
static ssize_t v86d_store(struct device_driver *dev, const char *buf,
size_t count)
{
strncpy(v86d_path, buf, PATH_MAX);
strncpy(v86d_path, buf, PATH_MAX - 1);
return count;
}
static DRIVER_ATTR_RW(v86d);
Expand Down

0 comments on commit 5a15468

Please sign in to comment.