From: Mauro Carvalho Chehab Date: Thu, 18 Jul 2024 11:01:00 +0000 (+0200) Subject: checkpatch.pl: warn also about strcat and sprintf usages X-Git-Tag: v0.8.2~57 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ae2d087e23e4c7c2f70e7e5d004bdcf933469af5;p=users%2Fmchehab%2Frasdaemon.git 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 --- 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