Skip to content

Commit

Permalink
dio: Fix buffer overflow in case of unknown board
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
geertu committed Jan 21, 2019
1 parent 800855e commit 627f192
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/dio/dio.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ static struct dioname names[] =
#undef DIONAME
#undef DIOFBNAME

static const char *unknowndioname
= "unknown DIO board -- please email <[email protected]>!";
static const char unknowndioname[]
= "unknown DIO board, please email [email protected]";

static const char *dio_getname(int id)
{
Expand Down

0 comments on commit 627f192

Please sign in to comment.