mirror of https://github.com/OISF/suricata
Import coccinelle test
This is a import of two coccinelle patches that detect problem on Packet handling. They are run on all commited C files in src by the script run_check.sh.remotes/origin/master-1.1.x
parent
66a15e2d6d
commit
d151314b4d
@ -0,0 +1,15 @@
|
|||||||
|
@directpacket@
|
||||||
|
identifier p;
|
||||||
|
typedef Packet;
|
||||||
|
position p1;
|
||||||
|
@@
|
||||||
|
|
||||||
|
Packet p@p1;
|
||||||
|
|
||||||
|
@ script:python @
|
||||||
|
p1 << directpacket.p1;
|
||||||
|
@@
|
||||||
|
|
||||||
|
print "Invalid Packet definition, explicit allocation must be used at %s:%s" % (p1[0].file, p1[0].line)
|
||||||
|
import sys
|
||||||
|
sys.exit(1)
|
@ -0,0 +1,25 @@
|
|||||||
|
@zeroed@
|
||||||
|
typedef Packet;
|
||||||
|
typedef uint8_t;
|
||||||
|
Packet *p;
|
||||||
|
position p1;
|
||||||
|
@@
|
||||||
|
|
||||||
|
memset(p@p1, 0, ...);
|
||||||
|
|
||||||
|
@isset@
|
||||||
|
Packet *p;
|
||||||
|
position zeroed.p1;
|
||||||
|
@@
|
||||||
|
|
||||||
|
memset(p@p1, 0, ...);
|
||||||
|
... when != p
|
||||||
|
p->pkt
|
||||||
|
|
||||||
|
@script:python depends on !isset@
|
||||||
|
p1 << zeroed.p1;
|
||||||
|
@@
|
||||||
|
|
||||||
|
print "Packet zeroed at %s:%s but pkt field is not set afterward." % (p1[0].file, p1[0].line)
|
||||||
|
import sys
|
||||||
|
sys.exit(1)
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for SMPL in *.cocci; do
|
||||||
|
echo "Testing cocci file: $SMPL"
|
||||||
|
for FILE in $(git ls-tree -r --name-only --full-tree HEAD src/ | grep -E '*.c$') ; do
|
||||||
|
spatch -sp_file $SMPL ../../$FILE 2>/dev/null || exit 1;
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue