Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Geert Uytterhoeven <geert@linux-m68k.org>

+2 -2
+2 -2
drivers/dio/dio.c
··· 89 89 #undef DIONAME 90 90 #undef DIOFBNAME 91 91 92 - static const char *unknowndioname 93 - = "unknown DIO board -- please email <linux-m68k@lists.linux-m68k.org>!"; 92 + static const char unknowndioname[] 93 + = "unknown DIO board, please email linux-m68k@lists.linux-m68k.org"; 94 94 95 95 static const char *dio_getname(int id) 96 96 {