[PATCH] parport: replace deprecated strcpy() with strscpy()

Miguel García posted 1 patch 3 months ago
drivers/parport/probe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] parport: replace deprecated strcpy() with strscpy()
Posted by Miguel García 3 months ago
strcpy() is deprecated for NUL-terminated strings due to the risk of
buffer overflows. This replaces it with strscpy(), using the passed
'len' argument to limit the copy size safely.


Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
---
 drivers/parport/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index 5d1b9aacb130..5f92f266bcb2 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -61,7 +61,7 @@ static void parse_data(struct parport *port, int device, char *str)
 		pr_warn("%s probe: memory squeeze\n", port->name);
 		return;
 	}
-	strcpy(txt, str);
+	strscpy(txt, str, strlen(str) + 1);
 	while (p) {
 		char *sep;
 		q = strchr(p, ';');
-- 
2.34.1