From ae2d087e23e4c7c2f70e7e5d004bdcf933469af5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 18 Jul 2024 13:01:00 +0200 Subject: [PATCH] checkpatch.pl: warn also about strcat and sprintf usages strcpy, strncpy and sprintf aren't safe, as they don't check buffer overflows. Change the checkpatch logic to warn about such usages. Signed-off-by: Mauro Carvalho Chehab --- scripts/checkpatch.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e81e509..7ed2ec6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6675,10 +6675,10 @@ sub process { # } # } -# strcpy should be avoided - if ($line =~ /\bstrcpy\s*\(/) { +# strcpy and strcat should be avoided + if ($line =~ /\b(strcpy|strcat|sprintf)\s*\(/) { WARN("STRCPY", - "Please avoid strcpy\n" . $herecurr); + "Please avoid $1 as it doesn't check buffer size\n" . $herecurr); } # ethtool_sprintf uses that should likely be ethtool_puts -- 2.50.1