checkpatch: Check for unsafe string functions
There are many string based functions that are unsafe
to use. Some of the functions are unsafe to use because
of the possibility of overflow while others cannot
guarantee that the resultant string is NULL-terminated.
Add check for these functions and log message indicating
which safe functions can be used instead.
Change-Id: Id305d98df241e3fd257529529739dcd4f3659186
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4396b07..46a49e7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2848,8 +2848,11 @@
# unbounded string functions are overflow risks
my %str_fns = (
"sprintf" => "snprintf",
- "strcpy" => "strncpy",
- "strcat" => "strncat",
+ "strcpy" => "strlcpy",
+ "strncpy" => "strlcpy",
+ "strcat" => "strlcat",
+ "strncat" => "strlcat",
+ "vsprintf" => "vsnprintf",
"strcmp" => "strncmp",
"strcasecmp" => "strncasecmp",
"strchr" => "strnchr",