Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58794009 authored by Gregory Bean's avatar Gregory Bean Committed by Bryan Huntsman
Browse files

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: default avatarGregory Bean <gbean@codeaurora.org>
(cherry picked from commit 15e1e97d66dd6a6039c1ec2bd549a632fe361128)
Signed-off-by: default avatarStepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: default avatarRishabh Bhatnagar <rishabhb@codeaurora.org>
parent 08d3bb46
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -5406,6 +5406,26 @@ sub process {
			      $herecurr);
		}

# unbounded string functions are overflow risks
		my %str_fns = (
			"sprintf" => "snprintf",
			"strcpy"  => "strlcpy",
			"strncpy"  => "strlcpy",
			"strcat"  => "strlcat",
			"strncat"  => "strlcat",
			"vsprintf"  => "vsnprintf",
			"strchr" => "strnchr",
			"strstr" => "strnstr",
		);
		foreach my $k (keys %str_fns) {
			if ($line =~ /\b$k\b/) {
				ERROR("UNBOUNDED_STRING_FNS",
				      "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_0",