From: Eric Leblond Date: Tue, 1 Jul 2014 17:27:34 +0000 (+0200) Subject: coccinelle: fix problem with coccinelle 1.0rc21 X-Git-Tag: suricata-2.1beta1~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d7982fae8c7bbc14cb3548ac929aa74b21d034bc;p=thirdparty%2Fsuricata.git coccinelle: fix problem with coccinelle 1.0rc21 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. --- diff --git a/qa/coccinelle/banned-functions.cocci b/qa/coccinelle/banned-functions.cocci index 82d116b089..bc2c60e6cb 100644 --- a/qa/coccinelle/banned-functions.cocci +++ b/qa/coccinelle/banned-functions.cocci @@ -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)