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>
(cherry picked from commit 665be0da353f69f85cb1acea19279adf6ccb5b52)
This commit is contained in:
Olav Haugan 2012-02-06 09:42:18 -08:00 committed by Stephen Boyd
parent 097d733966
commit fa79a44270

View file

@ -3352,8 +3352,11 @@ sub process {
# 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",