* truncation in drivers/video/fbdev/neofb.c
@ 2023-08-29 16:45 Nick Desaulniers
2023-08-29 17:11 ` Helge Deller
0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2023-08-29 16:45 UTC (permalink / raw)
To: Helge Deller
Cc: linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton,
Nathan Chancellor
Helge,
A recent change in clang made it better about spotting snprintf that
will result in truncation. Nathan reported the following instances:
drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
17 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1963:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
18 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1967:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
17 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1971:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
17 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1978:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
18 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1985:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
17 [-Wfortify-source]
drivers/video/fbdev/neofb.c:1992:3: warning: 'snprintf' will always be
truncated; specified size is 16, but format string expands to at least
18 [-Wfortify-source]
https://github.com/ClangBuiltLinux/linux/issues/1923
Clang is right here. `info->fix.id` is declared as `char id[16];` so
indeed string literals like "MagicGraph 256AV+" indeed lead to
truncation. But this is declared in include/uapi/linux/fb.h; I assume
those headers cant be changed? Can the strings be shortened then? Is
it perhaps time to delete this driver?
I see AKPM mentioned alluded to this in
commit 0e90454 ("neofb: avoid overwriting fb_info fields")
(Also, snprintf probably isn't necessary for string literals that
don't contain format strings)
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: truncation in drivers/video/fbdev/neofb.c 2023-08-29 16:45 truncation in drivers/video/fbdev/neofb.c Nick Desaulniers @ 2023-08-29 17:11 ` Helge Deller 2023-08-31 21:23 ` Helge Deller 0 siblings, 1 reply; 6+ messages in thread From: Helge Deller @ 2023-08-29 17:11 UTC (permalink / raw) To: Nick Desaulniers Cc: linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton, Nathan Chancellor On 8/29/23 18:45, Nick Desaulniers wrote: > Helge, > A recent change in clang made it better about spotting snprintf that > will result in truncation. Nathan reported the following instances: > > drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 17 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1963:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 18 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1967:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 17 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1971:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 17 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1978:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 18 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1985:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 17 [-Wfortify-source] > drivers/video/fbdev/neofb.c:1992:3: warning: 'snprintf' will always be > truncated; specified size is 16, but format string expands to at least > 18 [-Wfortify-source] > > https://github.com/ClangBuiltLinux/linux/issues/1923 > > Clang is right here. `info->fix.id` is declared as `char id[16];` so > indeed string literals like "MagicGraph 256AV+" indeed lead to > truncation. But this is declared in include/uapi/linux/fb.h; I assume > those headers cant be changed? Can the strings be shortened then? Is > it perhaps time to delete this driver? > > I see AKPM mentioned alluded to this in > commit 0e90454 ("neofb: avoid overwriting fb_info fields") > > (Also, snprintf probably isn't necessary for string literals that > don't contain format strings) It's just an ID field, so I don't think we need the full name of the card. So using strscpy() and shorten the name, e.g. "MagicGr. 256XL+" instead of "MagicGraph 256XL+" is probably the most simple solution? Anyone want to send a patch? Helge ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: truncation in drivers/video/fbdev/neofb.c 2023-08-29 17:11 ` Helge Deller @ 2023-08-31 21:23 ` Helge Deller 2023-08-31 21:41 ` Nick Desaulniers 0 siblings, 1 reply; 6+ messages in thread From: Helge Deller @ 2023-08-31 21:23 UTC (permalink / raw) To: Nick Desaulniers, linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton, Nathan Chancellor * Helge Deller <deller@gmx.de>: > On 8/29/23 18:45, Nick Desaulniers wrote: > > A recent change in clang made it better about spotting snprintf that > > will result in truncation. Nathan reported the following instances: > > > > drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be > > truncated; specified size is 16, but format string expands to at least > > 17 [-Wfortify-source] FYI, I've added the patch below to the fbdev for-next git tree. Helge From: Helge Deller <deller@gmx.de> Subject: [PATCH] fbdev: neofb: Shorten Neomagic product name in info struct Avoid those compiler warnings: neofb.c:1959:3: warning: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 17 [-Wfortify-source] Signed-off-by: Helge Deller <deller@gmx.de> Reported-by: Nathan Chancellor <nathan@kernel.org> Reported-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://lore.kernel.org/all/CAKwvOdn0xoVWjQ6ufM_rojtKb0f1i1hW-J_xYGfKDNFdHwaeHQ@mail.gmail.com/ Link: https://github.com/ClangBuiltLinux/linux/issues/1923 diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index d2f622b4c372..b905fe93b525 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -1948,49 +1948,40 @@ static struct fb_info *neo_alloc_fb_info(struct pci_dev *dev, switch (info->fix.accel) { case FB_ACCEL_NEOMAGIC_NM2070: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128"); + strscpy(info->fix.id, "MagicGraph128", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2090: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128V"); + strscpy(info->fix.id, "MagicGraph128V", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2093: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128ZV"); + strscpy(info->fix.id, "MagicGraph128ZV", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2097: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128ZV+"); + strscpy(info->fix.id, "Mag.Graph128ZV+", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2160: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128XD"); + strscpy(info->fix.id, "MagicGraph128XD", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2200: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256AV"); + strscpy(info->fix.id, "MagicGraph256AV", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2230: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256AV+"); + strscpy(info->fix.id, "MagicGraph256AV+", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2360: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256ZX"); + strscpy(info->fix.id, "MagicGraph256ZX", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2380: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256XL+"); + strscpy(info->fix.id, "MagicGraph256XL+", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: truncation in drivers/video/fbdev/neofb.c 2023-08-31 21:23 ` Helge Deller @ 2023-08-31 21:41 ` Nick Desaulniers 2023-08-31 22:15 ` Helge Deller 0 siblings, 1 reply; 6+ messages in thread From: Nick Desaulniers @ 2023-08-31 21:41 UTC (permalink / raw) To: Helge Deller Cc: linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton, Nathan Chancellor, Kees Cook, Justin Stitt On Thu, Aug 31, 2023 at 2:23 PM Helge Deller <deller@gmx.de> wrote: > > * Helge Deller <deller@gmx.de>: > > On 8/29/23 18:45, Nick Desaulniers wrote: > > > A recent change in clang made it better about spotting snprintf that > > > will result in truncation. Nathan reported the following instances: > > > > > > drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be > > > truncated; specified size is 16, but format string expands to at least > > > 17 [-Wfortify-source] > > FYI, I've added the patch below to the fbdev for-next git tree. > > Helge > > From: Helge Deller <deller@gmx.de> > Subject: [PATCH] fbdev: neofb: Shorten Neomagic product name in info struct > > Avoid those compiler warnings: > neofb.c:1959:3: warning: 'snprintf' will always be truncated; > specified size is 16, but format string expands to at least 17 [-Wfortify-source] > > Signed-off-by: Helge Deller <deller@gmx.de> > Reported-by: Nathan Chancellor <nathan@kernel.org> > Reported-by: Nick Desaulniers <ndesaulniers@google.com> > Link: https://lore.kernel.org/all/CAKwvOdn0xoVWjQ6ufM_rojtKb0f1i1hW-J_xYGfKDNFdHwaeHQ@mail.gmail.com/ > Link: https://github.com/ClangBuiltLinux/linux/issues/1923 This indeed makes the warning go away, but that's more so due to the use of strscpy now rather than snprintf. That alone is a good change but we still have definite truncation. See below: > > diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c > index d2f622b4c372..b905fe93b525 100644 > --- a/drivers/video/fbdev/neofb.c > +++ b/drivers/video/fbdev/neofb.c > @@ -1948,49 +1948,40 @@ static struct fb_info *neo_alloc_fb_info(struct pci_dev *dev, > > switch (info->fix.accel) { > case FB_ACCEL_NEOMAGIC_NM2070: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128"); > + strscpy(info->fix.id, "MagicGraph128", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2090: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128V"); > + strscpy(info->fix.id, "MagicGraph128V", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2093: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128ZV"); > + strscpy(info->fix.id, "MagicGraph128ZV", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2097: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128ZV+"); > + strscpy(info->fix.id, "Mag.Graph128ZV+", sizeof(info->fix.id)); I see the Mag.Graph change here; I'm curious why MagicGraph256XL+ didn't need that, too? MagicGraph128ZV+ MagicGraph256XL+ those look like the same number of characters; are they? Does this one need the `.` change? ``` diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index b905fe93b525..6b7836f7f809 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -1957,7 +1957,7 @@ static struct fb_info *neo_alloc_fb_info(struct pci_dev *dev, strscpy(info->fix.id, "MagicGraph128ZV", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2097: - strscpy(info->fix.id, "Mag.Graph128ZV+", sizeof(info->fix.id)); + strscpy(info->fix.id, "MagicGraph128ZV+", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2160: strscpy(info->fix.id, "MagicGraph128XD", sizeof(info->fix.id)); ``` Builds without error for me. Though I guess the compiler doesn't know what strscpy is semantically. Ah MagicGraph128ZV+ MagicGraph256XL+ are both 17 characters. (16 literal characters + trailing NUL) So MagicGraph256XL+ (and MagicGraph256AV+) below will fail to copy the NUL from the source, then overwrite the `+` with NUL IIUC. There's no ambiguity for MagicGraph256XL+, but now MagicGraph256AV+ would look like MagicGraph256AV which is another possible variant. Then perhaps MagicGraph256XL+ MagicGraph256AV+ and below might need to change. Sorry, initially it looked like a simple fix and I was ready to sign off on it; I hope I'm mistaken. Thank you for the patch, but do consider sending it to the ML for review before committing. > break; > case FB_ACCEL_NEOMAGIC_NM2160: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128XD"); > + strscpy(info->fix.id, "MagicGraph128XD", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2200: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256AV"); > + strscpy(info->fix.id, "MagicGraph256AV", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2230: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256AV+"); > + strscpy(info->fix.id, "MagicGraph256AV+", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2360: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256ZX"); > + strscpy(info->fix.id, "MagicGraph256ZX", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2380: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256XL+"); > + strscpy(info->fix.id, "MagicGraph256XL+", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; -- Thanks, ~Nick Desaulniers ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: truncation in drivers/video/fbdev/neofb.c 2023-08-31 21:41 ` Nick Desaulniers @ 2023-08-31 22:15 ` Helge Deller 2023-08-31 22:26 ` Nick Desaulniers 0 siblings, 1 reply; 6+ messages in thread From: Helge Deller @ 2023-08-31 22:15 UTC (permalink / raw) To: Nick Desaulniers Cc: linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton, Nathan Chancellor, Kees Cook, Justin Stitt * Nick Desaulniers <ndesaulniers@google.com>: > On Thu, Aug 31, 2023 at 2:23 PM Helge Deller <deller@gmx.de> wrote: > > > > * Helge Deller <deller@gmx.de>: > > > On 8/29/23 18:45, Nick Desaulniers wrote: > > > > A recent change in clang made it better about spotting snprintf that > > > > will result in truncation. Nathan reported the following instances: > > > > > > > > drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be > > > > truncated; specified size is 16, but format string expands to at least > > > > 17 [-Wfortify-source] > > > > FYI, I've added the patch below to the fbdev for-next git tree. > > [...] > > This indeed makes the warning go away, but that's more so due to the > use of strscpy now rather than snprintf. That alone is a good change > but we still have definite truncation. See below: > [...] Nick, thanks for your review and findings! Now every string should be max. 15 chars (which fits with the trailing NUL into the char[16] array). Helge Subject: [PATCH] fbdev: neofb: Shorten Neomagic product name in info struct Avoid those compiler warnings: neofb.c:1959:3: warning: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 17 [-Wfortify-source] Signed-off-by: Helge Deller <deller@gmx.de> Reported-by: Nathan Chancellor <nathan@kernel.org> Reported-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://lore.kernel.org/all/CAKwvOdn0xoVWjQ6ufM_rojtKb0f1i1hW-J_xYGfKDNFdHwaeHQ@mail.gmail.com/ Link: https://github.com/ClangBuiltLinux/linux/issues/1923 diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index d2f622b4c372..b58b11015c0c 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -1948,49 +1948,40 @@ static struct fb_info *neo_alloc_fb_info(struct pci_dev *dev, switch (info->fix.accel) { case FB_ACCEL_NEOMAGIC_NM2070: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128"); + strscpy(info->fix.id, "MagicGraph128", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2090: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128V"); + strscpy(info->fix.id, "MagicGraph128V", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2093: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128ZV"); + strscpy(info->fix.id, "MagicGraph128ZV", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2097: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128ZV+"); + strscpy(info->fix.id, "Mag.Graph128ZV+", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2160: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 128XD"); + strscpy(info->fix.id, "MagicGraph128XD", sizeof(info->fix.id)); break; case FB_ACCEL_NEOMAGIC_NM2200: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256AV"); + strscpy(info->fix.id, "MagicGraph256AV", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2230: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256AV+"); + strscpy(info->fix.id, "Mag.Graph256AV+", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2360: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256ZX"); + strscpy(info->fix.id, "MagicGraph256ZX", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; break; case FB_ACCEL_NEOMAGIC_NM2380: - snprintf(info->fix.id, sizeof(info->fix.id), - "MagicGraph 256XL+"); + strscpy(info->fix.id, "Mag.Graph256XL+", sizeof(info->fix.id)); info->flags |= FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: truncation in drivers/video/fbdev/neofb.c 2023-08-31 22:15 ` Helge Deller @ 2023-08-31 22:26 ` Nick Desaulniers 0 siblings, 0 replies; 6+ messages in thread From: Nick Desaulniers @ 2023-08-31 22:26 UTC (permalink / raw) To: Helge Deller Cc: linux-fbdev, dri-devel, clang-built-linux, LKML, Andrew Morton, Nathan Chancellor, Kees Cook, Justin Stitt On Thu, Aug 31, 2023 at 3:16 PM Helge Deller <deller@gmx.de> wrote: > > * Nick Desaulniers <ndesaulniers@google.com>: > > On Thu, Aug 31, 2023 at 2:23 PM Helge Deller <deller@gmx.de> wrote: > > > > > > * Helge Deller <deller@gmx.de>: > > > > On 8/29/23 18:45, Nick Desaulniers wrote: > > > > > A recent change in clang made it better about spotting snprintf that > > > > > will result in truncation. Nathan reported the following instances: > > > > > > > > > > drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be > > > > > truncated; specified size is 16, but format string expands to at least > > > > > 17 [-Wfortify-source] > > > > > > FYI, I've added the patch below to the fbdev for-next git tree. > > > [...] > > > > This indeed makes the warning go away, but that's more so due to the > > use of strscpy now rather than snprintf. That alone is a good change > > but we still have definite truncation. See below: > > [...] > > Nick, thanks for your review and findings! > Now every string should be max. 15 chars (which fits with the trailing > NUL into the char[16] array). > > Helge > > > Subject: [PATCH] fbdev: neofb: Shorten Neomagic product name in info struct > > Avoid those compiler warnings: > neofb.c:1959:3: warning: 'snprintf' will always be truncated; > specified size is 16, but format string expands to at least 17 [-Wfortify-source] > > Signed-off-by: Helge Deller <deller@gmx.de> > Reported-by: Nathan Chancellor <nathan@kernel.org> > Reported-by: Nick Desaulniers <ndesaulniers@google.com> > Link: https://lore.kernel.org/all/CAKwvOdn0xoVWjQ6ufM_rojtKb0f1i1hW-J_xYGfKDNFdHwaeHQ@mail.gmail.com/ > Link: https://github.com/ClangBuiltLinux/linux/issues/1923 ah yeah LGTM Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c > index d2f622b4c372..b58b11015c0c 100644 > --- a/drivers/video/fbdev/neofb.c > +++ b/drivers/video/fbdev/neofb.c > @@ -1948,49 +1948,40 @@ static struct fb_info *neo_alloc_fb_info(struct pci_dev *dev, > > switch (info->fix.accel) { > case FB_ACCEL_NEOMAGIC_NM2070: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128"); > + strscpy(info->fix.id, "MagicGraph128", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2090: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128V"); > + strscpy(info->fix.id, "MagicGraph128V", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2093: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128ZV"); > + strscpy(info->fix.id, "MagicGraph128ZV", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2097: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128ZV+"); > + strscpy(info->fix.id, "Mag.Graph128ZV+", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2160: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 128XD"); > + strscpy(info->fix.id, "MagicGraph128XD", sizeof(info->fix.id)); > break; > case FB_ACCEL_NEOMAGIC_NM2200: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256AV"); > + strscpy(info->fix.id, "MagicGraph256AV", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2230: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256AV+"); > + strscpy(info->fix.id, "Mag.Graph256AV+", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2360: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256ZX"); > + strscpy(info->fix.id, "MagicGraph256ZX", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > break; > case FB_ACCEL_NEOMAGIC_NM2380: > - snprintf(info->fix.id, sizeof(info->fix.id), > - "MagicGraph 256XL+"); > + strscpy(info->fix.id, "Mag.Graph256XL+", sizeof(info->fix.id)); > info->flags |= FBINFO_HWACCEL_IMAGEBLIT | > FBINFO_HWACCEL_COPYAREA | > FBINFO_HWACCEL_FILLRECT; > -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-31 22:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-29 16:45 truncation in drivers/video/fbdev/neofb.c Nick Desaulniers 2023-08-29 17:11 ` Helge Deller 2023-08-31 21:23 ` Helge Deller 2023-08-31 21:41 ` Nick Desaulniers 2023-08-31 22:15 ` Helge Deller 2023-08-31 22:26 ` 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).