public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: fbtft: use strncpy instead of strcpy
@ 2015-09-05 13:43 Sudip Mukherjee
  2015-09-05 13:43 ` [PATCH 2/3] staging: fbtft: do not use magic numbers Sudip Mukherjee
  2015-09-05 13:43 ` [PATCH 3/3] staging: fbtft: use pr_fmt Sudip Mukherjee
  0 siblings, 2 replies; 8+ messages in thread
From: Sudip Mukherjee @ 2015-09-05 13:43 UTC (permalink / raw)
  To: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman
  Cc: linux-kernel, devel, Sudip Mukherjee

Using strcpy() is a security risk as the destination buffer size is not
checked and we may over-run the buffer. Use strncpy() instead, while
mentioning the buffer size leaving place for the NULL termination.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/fbtft/fbtft_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index 0483d33..3856c88 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -1342,7 +1342,8 @@ static int __init fbtft_device_init(void)
 				p_name, p_num);
 			return -EINVAL;
 		}
-		strcpy(fbtft_device_param_gpios[i].name, p_name);
+		strncpy(fbtft_device_param_gpios[i].name, p_name,
+			FBTFT_GPIO_NAME_SIZE - 1);
 		fbtft_device_param_gpios[i++].gpio = (int) val;
 		if (i == MAX_GPIOS) {
 			pr_err(DRVNAME
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-11 10:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-05 13:43 [PATCH 1/3] staging: fbtft: use strncpy instead of strcpy Sudip Mukherjee
2015-09-05 13:43 ` [PATCH 2/3] staging: fbtft: do not use magic numbers Sudip Mukherjee
2015-09-05 13:43 ` [PATCH 3/3] staging: fbtft: use pr_fmt Sudip Mukherjee
2015-09-09 18:35   ` Greg Kroah-Hartman
2015-09-09 21:20     ` Noralf Trønnes
2015-09-10  4:54       ` Sudip Mukherjee
2015-09-10 16:45         ` Noralf Trønnes
2015-09-11 10:38           ` Sudip Mukherjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox