* [PATCH] video/hdmi: prefer strlcpy to strncpy
@ 2018-05-29 6:59 Nick Desaulniers
2018-05-30 1:58 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Nick Desaulniers @ 2018-05-29 6:59 UTC (permalink / raw)
To: b.zolnierkie; +Cc: Nick Desaulniers, dri-devel, linux-fbdev, linux-kernel
Fixes a stringop-truncation warning from gcc-8.
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
---
drivers/video/hdmi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 111a0ab..46c184c 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -168,8 +168,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
frame->version = 1;
frame->length = HDMI_SPD_INFOFRAME_SIZE;
- strncpy(frame->vendor, vendor, sizeof(frame->vendor));
- strncpy(frame->product, product, sizeof(frame->product));
+ strlcpy(frame->vendor, vendor, sizeof(frame->vendor));
+ strlcpy(frame->product, product, sizeof(frame->product));
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] video/hdmi: prefer strlcpy to strncpy
2018-05-29 6:59 [PATCH] video/hdmi: prefer strlcpy to strncpy Nick Desaulniers
@ 2018-05-30 1:58 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2018-05-30 1:58 UTC (permalink / raw)
To: b.zolnierkie
Cc: Nick Desaulniers, dri-devel, linux-fbdev,
Linux Kernel Mailing List, ebiggers
On Mon, May 28, 2018 at 11:59 PM, Nick Desaulniers
<nick.desaulniers@gmail.com> wrote:
> Fixes a stringop-truncation warning from gcc-8.
>
> Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
> ---
> drivers/video/hdmi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> index 111a0ab..46c184c 100644
> --- a/drivers/video/hdmi.c
> +++ b/drivers/video/hdmi.c
> @@ -168,8 +168,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
> frame->version = 1;
> frame->length = HDMI_SPD_INFOFRAME_SIZE;
>
> - strncpy(frame->vendor, vendor, sizeof(frame->vendor));
> - strncpy(frame->product, product, sizeof(frame->product));
> + strlcpy(frame->vendor, vendor, sizeof(frame->vendor));
> + strlcpy(frame->product, product, sizeof(frame->product));
>
> return 0;
> }
> --
> 2.7.4
>
Eric points out this can leak kernel memory if size is less than length of src.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-30 1:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29 6:59 [PATCH] video/hdmi: prefer strlcpy to strncpy Nick Desaulniers
2018-05-30 1:58 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).