]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dio: Fix buffer overflow in case of unknown board
authorGeert Uytterhoeven <geert@linux-m68k.org>
Tue, 8 Jan 2019 14:00:03 +0000 (15:00 +0100)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 21 Jan 2019 09:36:53 +0000 (10:36 +0100)
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>
drivers/dio/dio.c

index 92e78d16b476550c365baad796e82a50f7ba0191..c9aa15fb86a9aed095efe77bf95e297afdca29e1 100644 (file)
@@ -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)
 {