summaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-03-06 13:27:51 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-03-07 11:08:05 +0100
commit7f963a19ecbceef5d7e95e677ccc089d04ef987f (patch)
tree459db8c1b5d5243e9b5e3ebfd3e8974131d321de /lib/checksrc.pl
parent9ceee69ff7d6139de759a4f25051e0d661e0c2b0 (diff)
downloadcurl-7f963a19ecbceef5d7e95e677ccc089d04ef987f.tar.gz
checksrc: ban unsafe functions
The list of unsafe functions currently consists of sprintf, vsprintf, strcat, strncat and gets. Subsequently, some existing code needed updating to avoid warnings on this.
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 9f5058ddb..f561492a7 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -6,7 +6,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 2011 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -153,6 +153,12 @@ sub scanfile {
checkwarn($line, length($1)+1, $file, $l, "missing space after close paren");
}
+ # scan for use of banned functions
+ if($l =~ /^(.*\W)(sprintf|vsprintf|strcat|strncat|gets)\s*\(/) {
+ checkwarn($line, length($1), $file, $l,
+ "use of $2 is banned");
+ }
+
# check for open brace first on line but not first column
# only alert if previous line ended with a close paren and wasn't a cpp
# line