mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
checkpatch: deprecate unbounded string functions.
Unbounded string functions are overflow risks. The 'n' versions of those functions should be used instead. Change-Id: Ice0fb3ebdae9aa88cc7e764ffdf68cbed857febf Signed-off-by: Gregory Bean <gbean@codeaurora.org> (cherry picked from commit 15e1e97d66dd6a6039c1ec2bd549a632fe361128)
This commit is contained in:
parent
55bb2c050a
commit
3a4c8c77cc
1 changed files with 19 additions and 0 deletions
|
@ -3272,6 +3272,25 @@ sub process {
|
|||
$herecurr);
|
||||
}
|
||||
|
||||
# unbounded string functions are overflow risks
|
||||
my %str_fns = (
|
||||
"sprintf" => "snprintf",
|
||||
"strcpy" => "strncpy",
|
||||
"strcat" => "strncat",
|
||||
"strcmp" => "strncmp",
|
||||
"strcasecmp" => "strncasecmp",
|
||||
"strchr" => "strnchr",
|
||||
"strstr" => "strnstr",
|
||||
"strlen" => "strnlen",
|
||||
);
|
||||
foreach my $k (keys %str_fns) {
|
||||
if ($line =~ /\b$k\b/) {
|
||||
ERROR("Use of $k is deprecated: " .
|
||||
"use $str_fns{$k} instead.\n" .
|
||||
$herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
# warn about #if 0
|
||||
if ($line =~ /^.\s*\#\s*if\s+0\b/) {
|
||||
WARN("if this code is redundant consider removing it\n"
|
||||
|
|
Loading…
Reference in a new issue