[sheepdog] [PATCH 1/2] checkpath: warn if we use strncpy()/strcpy()

Liu Yuan namei.unix at gmail.com
Wed Mar 4 07:49:04 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..9762110 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("STRCPY", "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