]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools: add lints for unsafe functions
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 8 May 2019 15:46:29 +0000 (15:46 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 8 May 2019 15:55:54 +0000 (15:55 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
tools/checkpatch.pl

index 77e6e9a3301fc79e0d53d62f0b6862f100b94539..1b48d10a09a0cab9b810a5c2017f9ef26730d28f 100755 (executable)
@@ -6347,6 +6347,35 @@ sub process {
                             "Please, only use 32 bit atomics.\n" . $herecurr);
                }
 
+# check for use of strcpy()
+               if ($line =~ /\bstrcpy\s*\(.*\)/) {
+                       ERROR("STRCPY",
+                             "strcpy() is error-prone; please use strlcpy()"  . $herecurr);
+               }
+
+# check for use of strncpy()
+               if ($line =~ /\bstrncpy\s*\(.*\)/) {
+                       WARN("STRNCPY",
+                            "strncpy() is error-prone; please use strlcpy() if possible, or memcpy()"  . $herecurr);
+               }
+
+# check for use of strcat()
+               if ($line =~ /\bstrcat\s*\(.*\)/) {
+                       ERROR("STRCAT",
+                             "strcat() is error-prone; please use strlcat() if possible"  . $herecurr);
+               }
+
+# check for use of strncat()
+               if ($line =~ /\bstrncat\s*\(.*\)/) {
+                       WARN("STRNCAT",
+                            "strncat() is error-prone; please use strlcat() if possible"  . $herecurr);
+               }
+
+# check for use of bzero()
+               if ($line =~ /\bbzero\s*\(.*\)/) {
+                       ERROR("BZERO",
+                             "bzero() is deprecated; use memset()"  . $herecurr);
+               }
        }
 
        # If we have no input at all, then there is nothing to report on