]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
coccinelle: fix problem with coccinelle 1.0rc21
authorEric Leblond <eric@regit.org>
Tue, 1 Jul 2014 17:27:34 +0000 (19:27 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 29 Jul 2014 08:17:41 +0000 (10:17 +0200)
coccinelle 1.0rc21 has a problem with regular expression handling.
This result in a Fatal Error when test system detects an coding
error.

This patch fixes the problem by using a simple blob inside
semantic patch instead of using a regular expression to define
the function.

It also fixes add an optimization on matching suppressing a
useless <.. ..> construction.

Fixes have been suggested by Julia Lawall.

qa/coccinelle/banned-functions.cocci

index 82d116b08945e35afa0cd9f81644ca1f0d8a1be8..bc2c60e6cbae496236d65062d00dbdf9040e8726 100644 (file)
@@ -1,17 +1,15 @@
 @banned@
-identifier func =~ "^(sprintf|strcat|strcpy|strncpy|strncat|strndup|strchrdup)$";
+identifier i;
 position p1;
 @@
 
-<+...
-func(...)@p1
-...+>
+\(sprintf@i\|strcat@i\|strcpy@i\|strncpy@i\|strncat@i\|strndup@i\|strchrdup@i\)(...)@p1
 
-@ script:python @
+@script:python@
 p1 << banned.p1;
-func << banned.func;
+i << banned.i;
 @@
 
-print "Banned function %s() used at %s:%s" % (func, p1[0].file, p1[0].line)
+print("Banned function '%s' used at %s:%s" % (i, p1[0].file, p1[0].line))
 import sys
 sys.exit(1)