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 <mchehab+huawei@kernel.org>
# }
# }
-# 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