[sheepdog] [PATCH 1/2] checkpath: warn if we use strncpy()/strcpy()
Liu Yuan
namei.unix at gmail.com
Wed Mar 4 07:46:50 CET 2015
From: Liu Yuan <liuyuan at cmss.chinamobile.com>
Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
---
script/checkpatch.pl | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/script/checkpatch.pl b/script/checkpatch.pl
index a00e43d..6106e7e 100755
--- a/script/checkpatch.pl
+++ b/script/checkpatch.pl
@@ -2876,6 +2876,11 @@ sub process {
ERROR("SPRINTF", "sprintf() is not buffer safe, use snprintf()\n" . $herecurr);
}
+# forbid strncpy/strcpy
+ if ($line =~ /\bstrncpy|\bstrcpy\(/) {
+ ERROR("SPRINTF", "strncpy()/strcpy is not buffer safe, use pstrcpy()\n" . $herecurr);
+ }
+
# 1. forbid empty lines after break; of a switch statement
# e.g.
# + break;
--
1.9.1
More information about the sheepdog
mailing list