Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 627f192d authored by Geert Uytterhoeven's avatar Geert Uytterhoeven
Browse files

dio: Fix buffer overflow in case of unknown board



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: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 800855ea
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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)
{