[sheepdog] [PATCH 5/6] checkpatch: forbid none buffer safe sprintf()

Liu Yuan namei.unix at gmail.com
Sun Jan 27 08:43:46 CET 2013


From: Liu Yuan <tailai.ly at taobao.com>

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 script/checkpatch.pl |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/script/checkpatch.pl b/script/checkpatch.pl
index a096dbe..b340eb1 100755
--- a/script/checkpatch.pl
+++ b/script/checkpatch.pl
@@ -2846,6 +2846,11 @@ sub process {
 			ERROR("BZERO", "bzero() is obsolete, use memset()\n" . $herecurr);
 		}
 
+# forbid sprintf()
+		if ($line =~ /\bsprintf\(/) {
+			ERROR("SPRINTF", "sprintf() is not buffer save, use snprintf()\n" . $herecurr);
+		}
+
 # 1. forbid empty lines after break; of a switch statement
 # e.g.
 # +        break;
-- 
1.7.9.5




More information about the sheepdog mailing list