linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dio: Fix buffer overflow in case of unknown board
@ 2019-01-21  9:24 Geert Uytterhoeven
  2019-01-21  9:43 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2019-01-21  9:24 UTC (permalink / raw)
  To: Kars de Jong; +Cc: linux-m68k, linux-kernel, Geert Uytterhoeven

With gcc 8.2.0:

    drivers/dio/dio.c: In function ‘dio_init’:
    drivers/dio/dio.c:240:17: warning: ‘strcpy’ writing 69 or more bytes into a region of size 64 overflows the destination [-Wstringop-overflow=]
		     strcpy(dev->name,dio_getname(dev->id));
		     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Indeed, if an unknown board is present, the target buffer will overflow.
Shorten the unknown board name string to fix this, and declare it as an
array while at it.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
v2:
  - Declare unknowndioname as an array.
---
 drivers/dio/dio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 92e78d16b476550c..c9aa15fb86a9aed0 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -89,8 +89,8 @@ static struct dioname names[] =
 #undef DIONAME
 #undef DIOFBNAME
 
-static const char *unknowndioname 
-        = "unknown DIO board -- please email <linux-m68k@lists.linux-m68k.org>!";
+static const char unknowndioname[]
+	= "unknown DIO board, please email linux-m68k@lists.linux-m68k.org";
 
 static const char *dio_getname(int id)
 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] dio: Fix buffer overflow in case of unknown board
  2019-01-21  9:24 [PATCH v2] dio: Fix buffer overflow in case of unknown board Geert Uytterhoeven
@ 2019-01-21  9:43 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2019-01-21  9:43 UTC (permalink / raw)
  To: Kars de Jong; +Cc: linux-m68k, Linux Kernel Mailing List

On Mon, Jan 21, 2019 at 10:24 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> With gcc 8.2.0:
>
>     drivers/dio/dio.c: In function ‘dio_init’:
>     drivers/dio/dio.c:240:17: warning: ‘strcpy’ writing 69 or more bytes into a region of size 64 overflows the destination [-Wstringop-overflow=]
>                      strcpy(dev->name,dio_getname(dev->id));
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Indeed, if an unknown board is present, the target buffer will overflow.
> Shorten the unknown board name string to fix this, and declare it as an
> array while at it.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks, applied and queued for v5.1.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-21  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21  9:24 [PATCH v2] dio: Fix buffer overflow in case of unknown board Geert Uytterhoeven
2019-01-21  9:43 ` Geert Uytterhoeven

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).