[PATCH v2 26/28] video: fbdev: uvesafb: Fix string related warnings
Thomas Zimmermann
tzimmermann at suse.de
Tue Dec 1 14:19:56 UTC 2020
Hi
Am 28.11.20 um 23:41 schrieb Sam Ravnborg:
> 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 <sam at ravnborg.org>
> Cc: Michal Januszewski <spock at gentoo.org>
> Cc: linux-fbdev at vger.kernel.org
> ---
> drivers/video/fbdev/uvesafb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
> index 8ee0fc9c63cf..45dc8da191e4 100644
> --- a/drivers/video/fbdev/uvesafb.c
> +++ b/drivers/video/fbdev/uvesafb.c
> @@ -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) {
> @@ -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);
From lookign a the drive rcode, I assume that the code never touches
the final byte in v86d_path. So it remains \0 indefinitely.
Acked-by: Thomas Zimmermann <tzimmermann at suse.de>
> return count;
> }
> static DRIVER_ATTR_RW(v86d);
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20201201/2d9ef6b9/attachment.sig>
More information about the dri-devel
mailing list