summaryrefslogtreecommitdiffstats
path: root/qa/coccinelle
diff options
context:
space:
mode:
Diffstat (limited to 'qa/coccinelle')
-rw-r--r--qa/coccinelle/Makefile.am22
-rw-r--r--qa/coccinelle/Makefile.in547
-rw-r--r--qa/coccinelle/access-pkt-packet.cocci55
-rw-r--r--qa/coccinelle/banned-functions.cocci15
-rw-r--r--qa/coccinelle/direct-packet.cocci15
-rw-r--r--qa/coccinelle/malloc-error-check.cocci69
-rw-r--r--qa/coccinelle/pktnotset-packet.cocci29
-rw-r--r--qa/coccinelle/realloc.cocci18
-rwxr-xr-xqa/coccinelle/run_check.sh50
-rw-r--r--qa/coccinelle/siginit.cocci26
-rw-r--r--qa/coccinelle/size_t.cocci44
-rwxr-xr-xqa/coccinelle/struct-flags.py121
-rw-r--r--qa/coccinelle/sz3.cocci48
-rw-r--r--qa/coccinelle/uint.cocci13
14 files changed, 1072 insertions, 0 deletions
diff --git a/qa/coccinelle/Makefile.am b/qa/coccinelle/Makefile.am
new file mode 100644
index 0000000..1f78a74
--- /dev/null
+++ b/qa/coccinelle/Makefile.am
@@ -0,0 +1,22 @@
+EXTRA_DIST= access-pkt-packet.cocci \
+ banned-functions.cocci \
+ direct-packet.cocci \
+ malloc-error-check.cocci \
+ pktnotset-packet.cocci \
+ realloc.cocci \
+ siginit.cocci \
+ size_t.cocci \
+ sz3.cocci \
+ uint.cocci \
+ run_check.sh struct-flags.py
+
+if HAVE_COCCINELLE
+struct-flags.cocci:
+ $(srcdir)/struct-flags.py $(top_srcdir)/src > $(top_builddir)/qa/coccinelle/struct-flags.cocci
+
+check: struct-flags.cocci
+ TOP_BUILDDIR=${abs_top_builddir} TOP_SRCDIR=$(abs_top_srcdir) $(top_srcdir)/qa/coccinelle/run_check.sh
+
+distclean-local:
+ -rm $(top_builddir)/qa/coccinelle/struct-flags.cocci
+endif
diff --git a/qa/coccinelle/Makefile.in b/qa/coccinelle/Makefile.in
new file mode 100644
index 0000000..da64830
--- /dev/null
+++ b/qa/coccinelle/Makefile.in
@@ -0,0 +1,547 @@
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = qa/coccinelle
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/autoconf.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CARGO = @CARGO@
+CARGO_BUILD_TARGET = @CARGO_BUILD_TARGET@
+CARGO_HOME = @CARGO_HOME@
+CBINDGEN = @CBINDGEN@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLANG = @CLANG@
+CLANG_CFLAGS = @CLANG_CFLAGS@
+CONFIGURE_DATAROOTDIR = @CONFIGURE_DATAROOTDIR@
+CONFIGURE_LOCALSTATEDIR = @CONFIGURE_LOCALSTATEDIR@
+CONFIGURE_PREFIX = @CONFIGURE_PREFIX@
+CONFIGURE_SYSCONDIR = @CONFIGURE_SYSCONDIR@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ETAGS = @ETAGS@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FILECMD = @FILECMD@
+GCC_CFLAGS = @GCC_CFLAGS@
+GREP = @GREP@
+HAVE_COCCINELLE_CONFIG = @HAVE_COCCINELLE_CONFIG@
+HAVE_CURL = @HAVE_CURL@
+HAVE_CYGPATH = @HAVE_CYGPATH@
+HAVE_GETCONF_CMD = @HAVE_GETCONF_CMD@
+HAVE_GIT_CMD = @HAVE_GIT_CMD@
+HAVE_PCAP_CONFIG = @HAVE_PCAP_CONFIG@
+HAVE_PDFLATEX = @HAVE_PDFLATEX@
+HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
+HAVE_PYTHON = @HAVE_PYTHON@
+HAVE_WGET = @HAVE_WGET@
+HTP_DIR = @HTP_DIR@
+HTP_LDADD = @HTP_LDADD@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBHTPDEVVERSION_CFLAGS = @LIBHTPDEVVERSION_CFLAGS@
+LIBHTPDEVVERSION_LIBS = @LIBHTPDEVVERSION_LIBS@
+LIBHTPMINVERSION_CFLAGS = @LIBHTPMINVERSION_CFLAGS@
+LIBHTPMINVERSION_LIBS = @LIBHTPMINVERSION_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_FUZZING_ENGINE = @LIB_FUZZING_ENGINE@
+LIPO = @LIPO@
+LLC = @LLC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+LUAJIT_CFLAGS = @LUAJIT_CFLAGS@
+LUAJIT_LIBS = @LUAJIT_LIBS@
+LUA_CFLAGS = @LUA_CFLAGS@
+LUA_INT8 = @LUA_INT8@
+LUA_LIBS = @LUA_LIBS@
+MAJOR_MINOR = @MAJOR_MINOR@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPTIMIZATION_CFLAGS = @OPTIMIZATION_CFLAGS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCAP_CFLAGS = @PCAP_CFLAGS@
+PCAP_LIBS = @PCAP_LIBS@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+RUSTC = @RUSTC@
+RUSTUP_HOME_PATH = @RUSTUP_HOME_PATH@
+RUST_FEATURES = @RUST_FEATURES@
+RUST_LDADD = @RUST_LDADD@
+RUST_SURICATA_LIB = @RUST_SURICATA_LIB@
+RUST_SURICATA_LIBDIR = @RUST_SURICATA_LIBDIR@
+RUST_SURICATA_LIBNAME = @RUST_SURICATA_LIBNAME@
+SECCFLAGS = @SECCFLAGS@
+SECLDFLAGS = @SECLDFLAGS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SPHINX_BUILD = @SPHINX_BUILD@
+STRIP = @STRIP@
+SURICATA_UPDATE_DIR = @SURICATA_UPDATE_DIR@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+e_datadir = @e_datadir@
+e_datarulesdir = @e_datarulesdir@
+e_defaultruledir = @e_defaultruledir@
+e_enable_evelog = @e_enable_evelog@
+e_localstatedir = @e_localstatedir@
+e_logcertsdir = @e_logcertsdir@
+e_logdir = @e_logdir@
+e_logfilesdir = @e_logfilesdir@
+e_magic_file = @e_magic_file@
+e_magic_file_comment = @e_magic_file_comment@
+e_rundir = @e_rundir@
+e_rustdir = @e_rustdir@
+e_sysconfdir = @e_sysconfdir@
+enable_non_bundled_htp = @enable_non_bundled_htp@
+exec_prefix = @exec_prefix@
+have_rustup = @have_rustup@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+install_suricata_update_reason = @install_suricata_update_reason@
+libdir = @libdir@
+libexecdir = @libexecdir@
+libhs_CFLAGS = @libhs_CFLAGS@
+libhs_LIBS = @libhs_LIBS@
+libhtp_CFLAGS = @libhtp_CFLAGS@
+libhtp_LIBS = @libhtp_LIBS@
+libnetfilter_queue_CFLAGS = @libnetfilter_queue_CFLAGS@
+libnetfilter_queue_LIBS = @libnetfilter_queue_LIBS@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+runstatedir = @runstatedir@
+rust_vendor_comment = @rust_vendor_comment@
+rustup_home = @rustup_home@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = access-pkt-packet.cocci \
+ banned-functions.cocci \
+ direct-packet.cocci \
+ malloc-error-check.cocci \
+ pktnotset-packet.cocci \
+ realloc.cocci \
+ siginit.cocci \
+ size_t.cocci \
+ sz3.cocci \
+ uint.cocci \
+ run_check.sh struct-flags.py
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu qa/coccinelle/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu qa/coccinelle/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+@HAVE_COCCINELLE_FALSE@distclean-local:
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-local
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distclean-local distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+@HAVE_COCCINELLE_TRUE@struct-flags.cocci:
+@HAVE_COCCINELLE_TRUE@ $(srcdir)/struct-flags.py $(top_srcdir)/src > $(top_builddir)/qa/coccinelle/struct-flags.cocci
+
+@HAVE_COCCINELLE_TRUE@check: struct-flags.cocci
+@HAVE_COCCINELLE_TRUE@ TOP_BUILDDIR=${abs_top_builddir} TOP_SRCDIR=$(abs_top_srcdir) $(top_srcdir)/qa/coccinelle/run_check.sh
+
+@HAVE_COCCINELLE_TRUE@distclean-local:
+@HAVE_COCCINELLE_TRUE@ -rm $(top_builddir)/qa/coccinelle/struct-flags.cocci
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/qa/coccinelle/access-pkt-packet.cocci b/qa/coccinelle/access-pkt-packet.cocci
new file mode 100644
index 0000000..3402b6d
--- /dev/null
+++ b/qa/coccinelle/access-pkt-packet.cocci
@@ -0,0 +1,55 @@
+@init@
+typedef Packet;
+Packet *p;
+expression E;
+statement S;
+@@
+
+(
+memset(p, ...);
+p->pkt = E;
+|
+p = SCCalloc(...);
+S
+p->pkt = E;
+)
+
+@pktfield depends on !init@
+identifier func !~ "^PacketCopyDataOffset$";
+Packet *p;
+position p1;
+@@
+
+func(...) {
+<...
+p->pkt@p1
+...>
+}
+
+@ script:python @
+p1 << pktfield.p1;
+@@
+
+print("Invalid Packet->pkt usage, GET_PKT_DATA macro must be used at %s:%s" % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
+
+@pktlenfield@
+identifier func !~ "^PacketCopyDataOffset$";
+Packet *p;
+position p1;
+@@
+
+func(...) {
+<...
+p->pktlen@p1
+...>
+}
+
+@ script:python @
+p1 << pktlenfield.p1;
+@@
+
+print("Invalid Packet->pktlen usage, GET_PKT_LEN macro must be used at %s:%s" % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/banned-functions.cocci b/qa/coccinelle/banned-functions.cocci
new file mode 100644
index 0000000..1bd127e
--- /dev/null
+++ b/qa/coccinelle/banned-functions.cocci
@@ -0,0 +1,15 @@
+@banned@
+identifier i;
+position p1;
+@@
+
+\(strtok@i\|sprintf@i\|strcat@i\|strcpy@i\|strncpy@i\|strncat@i\|strchrnul@i\|atoi@i\|rand@i\|rand_r@i\|index@i\|rindex@i\|bzero@i\)(...)@p1
+
+@script:python@
+p1 << banned.p1;
+i << banned.i;
+@@
+
+print("Banned function '%s' used at %s:%s" % (i, p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/direct-packet.cocci b/qa/coccinelle/direct-packet.cocci
new file mode 100644
index 0000000..b184225
--- /dev/null
+++ b/qa/coccinelle/direct-packet.cocci
@@ -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)
diff --git a/qa/coccinelle/malloc-error-check.cocci b/qa/coccinelle/malloc-error-check.cocci
new file mode 100644
index 0000000..ce4d0cc
--- /dev/null
+++ b/qa/coccinelle/malloc-error-check.cocci
@@ -0,0 +1,69 @@
+@malloced@
+expression x;
+position p1;
+identifier func =~ "(SCMalloc|SCStrdup|SCCalloc|SCMallocAligned|SCRealloc)";
+@@
+
+x@p1 = func(...)
+
+@inlinetested@
+expression x, E;
+statement S;
+position malloced.p1;
+identifier func =~ "(SCMalloc|SCStrdup|SCCalloc|SCMallocAligned|SCRealloc)";
+@@
+
+(
+if ((x@p1 = func(...)) == NULL) S
+|
+if (E && (x@p1 = func(...)) == NULL) S
+)
+
+@realloc exists@
+position malloced.p1;
+expression x, E1;
+identifier func =~ "(SCMalloc|SCCalloc|SCMallocAligned)";
+@@
+
+x@p1 = func(...)
+... when != x
+x = SCRealloc(x, E1)
+
+@istested depends on !realloc exists@
+expression x, E1;
+position malloced.p1;
+statement S1, S2;
+identifier func =~ "(SCMalloc|SCStrdup|SCCalloc|SCMallocAligned|SCRealloc)";
+@@
+
+x@p1 = func(...)
+... when != x
+(
+if (unlikely(x == NULL)) S1
+|
+if (unlikely(x == NULL)) S1 else S2
+|
+if (likely(x != NULL)) S1
+|
+if (x == NULL) S1
+|
+if (x != NULL) S1 else S2
+|
+if (x && E1) S1
+|
+BUG_ON(x == NULL)
+|
+FAIL_IF(x == NULL)
+|
+FAIL_IF(unlikely(x == NULL))
+|
+FAIL_IF_NULL(x)
+)
+
+
+@script:python depends on !realloc && !istested && !inlinetested@
+p1 << malloced.p1;
+@@
+print("Structure malloced at %s:%s but error is not checked." % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/pktnotset-packet.cocci b/qa/coccinelle/pktnotset-packet.cocci
new file mode 100644
index 0000000..1b10599
--- /dev/null
+++ b/qa/coccinelle/pktnotset-packet.cocci
@@ -0,0 +1,29 @@
+@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
+|
+PacketInit(p)
+)
+
+@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)
diff --git a/qa/coccinelle/realloc.cocci b/qa/coccinelle/realloc.cocci
new file mode 100644
index 0000000..e9c4fc6
--- /dev/null
+++ b/qa/coccinelle/realloc.cocci
@@ -0,0 +1,18 @@
+@realloc@
+expression x, E;
+type ty;
+position p1;
+@@
+
+(
+x@p1 = SCRealloc(x, E)
+|
+x@p1 = (ty *) SCRealloc(x, E)
+)
+
+@script:python@
+p1 << realloc.p1;
+@@
+print("Structure reallocated at %s:%s but original pointer is lost and not freed in case of error." % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/run_check.sh b/qa/coccinelle/run_check.sh
new file mode 100755
index 0000000..325e173
--- /dev/null
+++ b/qa/coccinelle/run_check.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+if [ $1 ]; then
+ case $1 in
+ *[ch])
+ LIST=$@;
+ PREFIX=$(git rev-parse --show-toplevel)/
+ ;;
+ *..*)
+ LIST=$(git diff --pretty="format:" --name-only $1 | grep -E '[ch]$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+ ;;
+ *)
+ LIST=$(git show --pretty="format:" --name-only $1 | grep -E '[ch]$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+ ;;
+ esac
+elif git rev-parse > /dev/null 2>&1; then
+ LIST=$(git ls-tree -r --name-only --full-tree HEAD src/ | grep -E '*.c$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+elif [ "${TOP_SRCDIR}" != "" ]; then
+ LIST=$(cd ${TOP_SRCDIR} && find src -name \*.[ch])
+ PREFIX=${TOP_SRCDIR}/
+fi
+
+if [ "${TOP_BUILDDIR}" != "" ]; then
+ BUILT_COCCI_FILES=$(ls ${TOP_BUILDDIR}/qa/coccinelle/*.cocci)
+else
+ BUILT_COCCI_FILES=""
+fi
+
+if [ -z "$CONCURRENCY_LEVEL" ]; then
+ CONCURRENCY_LEVEL=1
+ echo "No concurrency"
+else
+ echo "Using concurrency level $CONCURRENCY_LEVEL"
+fi
+
+for SMPL in ${PREFIX}qa/coccinelle/*.cocci ${BUILT_COCCI_FILES}; do
+ echo "Testing cocci file: $SMPL"
+ if command -v parallel >/dev/null; then
+ echo -n $LIST | parallel -d ' ' -j $CONCURRENCY_LEVEL spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS $PREFIX{} || if [ -z "$NOT_TERMINAL" ]; then exit 1; fi
+ else
+ for FILE in $LIST ; do
+ spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS $PREFIX$FILE || if [ -z "$NOT_TERMINAL" ]; then exit 1; fi
+ done
+ fi
+done
+
+exit 0
diff --git a/qa/coccinelle/siginit.cocci b/qa/coccinelle/siginit.cocci
new file mode 100644
index 0000000..2bfcbd6
--- /dev/null
+++ b/qa/coccinelle/siginit.cocci
@@ -0,0 +1,26 @@
+@siginit@
+identifier func =~ "Detect.*Setup";
+expression E1;
+position p1;
+identifier de_ctx, s, str, error;
+type DetectEngineCtx, Signature;
+@@
+
+func(DetectEngineCtx *de_ctx, Signature *s, char *str) {
+...
+SigMatchAppendSMToList(s, ...)@p1;
+...
+if (s->alproto != E1 && ...) {
+...
+goto error;
+}
+...
+}
+
+
+@script:python@
+p1 << siginit.p1;
+@@
+print("SigMatch added at %s:%s but error handling can cause it to be freed later." % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/size_t.cocci b/qa/coccinelle/size_t.cocci
new file mode 100644
index 0000000..89a13f8
--- /dev/null
+++ b/qa/coccinelle/size_t.cocci
@@ -0,0 +1,44 @@
+@sizet@
+size_t p;
+identifier func =~ "^(sprintf|printf|SCLog.*)$";
+identifier funcn =~ "^.*nprintf$";
+position p1;
+typedef uint16_t;
+typedef uint32_t;
+typedef uint64_t;
+expression E1, E2;
+@@
+
+(
+func(..., p, ...)@p1;
+|
+func(..., (int) p, ...)@p1;
+|
+func(..., (unsigned int) p, ...)@p1;
+|
+func(..., (uint16_t) p, ...)@p1;
+|
+func(..., (uint32_t) p, ...)@p1;
+|
+func(..., (uint64_t) p, ...)@p1;
+|
+funcn(E1, E2,..., p, ...)@p1;
+|
+funcn(E1, E2,..., (int) p, ...)@p1;
+|
+funcn(E1, E2,..., (unsigned int) p, ...)@p1;
+|
+funcn(E1, E2,..., (uint16_t) p, ...)@p1;
+|
+funcn(E1, E2,..., (uint32_t) p, ...)@p1;
+|
+funcn(E1, E2,..., (uint64_t) p, ...)@p1;
+)
+
+@ script:python @
+p1 << sizet.p1;
+@@
+
+print("Invalid printf with size_t (not casted to uintmax_t) at %s:%s" % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/struct-flags.py b/qa/coccinelle/struct-flags.py
new file mode 100755
index 0000000..3186cf6
--- /dev/null
+++ b/qa/coccinelle/struct-flags.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+import re
+import sys
+import os
+from string import Template
+
+if len(sys.argv) == 2:
+ SRC_DIR = sys.argv[1]
+else:
+ SRC_DIR = "../../src/"
+
+
+class Structure:
+ def __init__(self, string):
+ (self.struct, self.flags, self.values) = string.split(":")
+
+class SetterGetter:
+ def __init__(self, string):
+ (function, params, self.value) = string.split(":")
+ self.function = function.strip("()")
+ self.params = [int(a) for a in params.split(",")]
+
+
+cmd = "grep -h coccinelle ../../src/*[ch] | sed -e 's/.*coccinelle: \(.*\) \*\//\1/'"
+
+struct_list = []
+setter_getter_list = []
+
+dirList = os.listdir(SRC_DIR)
+for fname in dirList:
+ if re.search("\.[ch]$", fname):
+ for line in open(os.path.join(SRC_DIR, fname)):
+ if "coccinelle:" in line:
+ m = re.search("coccinelle: (.*) \*\/", line)
+ if "()" not in m.group(1):
+ struct = Structure(m.group(1))
+ struct_list.append(struct)
+ else:
+ function = SetterGetter(m.group(1))
+ setter_getter_list.append(function)
+
+header = "@flags@"
+body = []
+
+# Handle setter and getter
+setter_getter = [x.function for x in setter_getter_list]
+if len(setter_getter):
+ header += "\nidentifier NotSetterGetter !~ \"^(%s)$\";" % ("|".join(setter_getter))
+
+i = 0
+for struct in struct_list:
+ header += """
+%s *struct%d;
+identifier struct_flags%d =~ "^(?!%s).+";""" % (struct.struct, i, i, struct.values)
+
+ body.append("""
+struct%d->%s@p1 |= struct_flags%d
+|
+struct%d->%s@p1 & struct_flags%d
+|
+struct%d->%s@p1 &= ~struct_flags%d
+""" % (i, struct.flags, i, i, struct.flags, i, i, struct.flags, i))
+
+ i += 1
+
+print(header)
+print("position p1;")
+print("@@")
+print("")
+print("""
+NotSetterGetter(...)
+{
+ <...
+""")
+print("")
+print("(" + "|".join(body) + ")")
+print("")
+print("""
+...>
+}
+
+@script:python@
+p1 << flags.p1;
+@@
+
+print "Invalid usage of flags field at %s:%s, flags value is incorrect (wrong family)." % (p1[0].file, p1[0].line)
+import sys
+sys.exit(1)""")
+
+i = 1
+setter_template = """
+@settergetter${i}@
+identifier SetterGetter =~ "${function}";
+identifier f_flags =~ "^(?!${value}).+";
+identifier ${params_line};
+position p1;
+@@
+
+SetterGetter@p1(${prefix_param}f_flags${suffix_param})
+
+@script:python@
+p1 << settergetter${i}.p1;
+@@
+print "Invalid usage of ${function} at %s:%s, flags value is incorrect (wrong family)." % (p1[0].file, p1[0].line)
+import sys
+sys.exit(1)
+"""
+
+for sg in setter_getter_list:
+ prefix_param = ""
+ for index in list(range(1, sg.params[1])):
+ prefix_param += "param%d, " % (index)
+ if sg.params[1] < sg.params[0]:
+ suffix_param = ", " + ", ".join(["param%d" % (index + 1) for index in list(range(sg.params[1], sg.params[0]))])
+ else:
+ suffix_param = ""
+ params_elts = list(range(1, sg.params[1])) + list(range(sg.params[1] + 1, sg.params[0] + 1))
+ params_line = ", ".join(["param%d" % (x) for x in params_elts])
+ print(Template(setter_template).substitute(i=i, function=sg.function, value=sg.value,
+ prefix_param=prefix_param, suffix_param=suffix_param, params_line=params_line))
+ i += 1
diff --git a/qa/coccinelle/sz3.cocci b/qa/coccinelle/sz3.cocci
new file mode 100644
index 0000000..51459c7
--- /dev/null
+++ b/qa/coccinelle/sz3.cocci
@@ -0,0 +1,48 @@
+//
+// Take size of pointed value, not pointer
+//
+// Target: Linux, Generic
+// Copyright: 2012 - LIP6/INRIA
+// License: Licensed under GPLv2 or any later version.
+// Author: Julia Lawall <Julia.Lawall@lip6.fr>
+// URL: http://coccinelle.lip6.fr/
+// URL: http://coccinellery.org/
+// Modified by Eric Leblond <eric@regit.org> for suricata test system
+
+@preuse@
+expression *e;
+type T;
+identifier f;
+position p1;
+@@
+
+f(...,
+sizeof(e@p1)
+,...,(T)e,...)
+
+@ script:python @
+p1 << preuse.p1;
+@@
+
+print("Size of pointed value not pointer used at %s:%s" % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
+
+@postuse@
+expression *e;
+type T;
+identifier f;
+position p1;
+@@
+
+f(...,(T)e,...,
+sizeof(e@p1)
+,...)
+
+@ script:python @
+p1 << postuse.p1;
+@@
+
+print("Size of pointed value not pointer used at %s:%s" % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/uint.cocci b/qa/coccinelle/uint.cocci
new file mode 100644
index 0000000..d7e6af7
--- /dev/null
+++ b/qa/coccinelle/uint.cocci
@@ -0,0 +1,13 @@
+@uint@
+uint i;
+position p1;
+@@
+
+i@p1
+
+@script:python@
+p1 << uint.p1;
+@@
+print("banned type uint used at at %s:%s, please use a explicit length." % (p1[0].file, p1[0].line))
+import sys
+sys.exit(1)