summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-06 12:35:37 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-06 12:35:37 -0400
commit5927ed8d3324c39fd8aa3d496d119b37b97a1d73 (patch)
tree60fd91a8aaeaf9406658402537b350f7813563b6 /scripts
parent4e3f9c1f3af6292f30799f005f6df8f9c1bc7fee (diff)
downloadtor-5927ed8d3324c39fd8aa3d496d119b37b97a1d73.tar.gz
tor-5927ed8d3324c39fd8aa3d496d119b37b97a1d73.zip
checkSpace.pl now forbids more identifiers.
The functions it warns about are: assert, memcmp, strcat, strcpy, sprintf, malloc, free, realloc, strdup, strndup, calloc. Also, fix a few lingering instances of these in the code. Use other conventions to indicate _intended_ use of assert and malloc/realloc/etc.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/maint/checkSpace.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/maint/checkSpace.pl b/scripts/maint/checkSpace.pl
index 906281112d..e90f5b330b 100755
--- a/scripts/maint/checkSpace.pl
+++ b/scripts/maint/checkSpace.pl
@@ -156,6 +156,25 @@ for $fn (@ARGV) {
$in_func_head = 0;
}
}
+
+ ## Check for forbidden functions except when they are
+ # explicitly permitted
+ if (/\bassert\(/ && not /assert OK/) {
+ print "assert :$fn:$. (use tor_assert)\n";
+ }
+ if (/\bmemcmp\(/ && not /memcmp OK/) {
+ print "memcmp :$fn:$. (use {tor,fast}_mem{eq,neq,cmp}\n";
+ }
+ # always forbidden.
+ if (not / OVERRIDE /) {
+ if (/\bstrcat\(/ or /\bstrcpy\(/ or /\bsprintf\(/) {
+ print "$& :$fn:$.\n";
+ }
+ if (/\bmalloc\(/ or /\bfree\(/ or /\brealloc\(/ or
+ /\bstrdup\(/ or /\bstrndup\(/ or /\bcalloc\(/) {
+ print "$& :$fn:$. (use tor_malloc, tor_free, etc)\n";
+ }
+ }
}
}
## Warn if the file doesn't end with a blank line.