Skip to contentSkip to conversation

staging: fbtft: Fix buffer overflow vulnerability

PATCH Superseded Tobin C. Harding 2 participants 2 messages Feb 15, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: fbtft: Fix buffer overflow vulnerability

Module copies a user supplied string (module parameter) into a buffer using strncpy() and does not check that the buffer is null terminated.

Replace call to strncpy() with call to strlcpy() ensuring that the buffer is null terminated.

---
 drivers/staging/fbtft/fbtft_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft_device.c +1 -1
index de46f8d..7b7223b 100644
@@ -1483,7 +1483,7 @@ static int __init fbtft_device_init(void)
 			displays[i].pdev->name = name;
 			displays[i].spi = NULL;
 		} else {
-			strncpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
+			strlcpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
 			displays[i].pdev = NULL;
 		}
 	}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 16 lines · Tobin C. Harding

Module copies a user supplied string (module parameter) into a buffer using strncpy() and does not check that the buffer is null terminated.

Replace call to strncpy() with call to strlcpy() ensuring that the buffer is null terminated.

---
 drivers/staging/fbtft/fbtft_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft_device.c +0 -0
index de46f8d..7b7223b 100644

drivers/staging/fbtft/fbtft_device.c static int __init fbtft_device_init(void) · line 1486

Quoted 5 lines
drivers/staging/fbtft/fbtft_device.c +1 -1
@@ -1483,7 +1483,7 @@ static int __init fbtft_device_init(void)
 			displays[i].pdev->name = name;
 			displays[i].spi = NULL;
 		} else {
-			strncpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
+			strlcpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);

Shouldn't we properly check the return value here to know if the buffer did get truncated? Or do we really care?

thanks,

greg k-h