summaryrefslogtreecommitdiffstats
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/Makefile.am2
-rw-r--r--qa/Makefile.in704
-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
-rw-r--r--qa/drmemory.suppress111
-rwxr-xr-xqa/sock_to_gzip_file.py57
-rwxr-xr-xqa/wirefuzz.pl709
19 files changed, 2655 insertions, 0 deletions
diff --git a/qa/Makefile.am b/qa/Makefile.am
new file mode 100644
index 0000000..e5f77dc
--- /dev/null
+++ b/qa/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = coccinelle
+EXTRA_DIST = wirefuzz.pl sock_to_gzip_file.py drmemory.suppress
diff --git a/qa/Makefile.in b/qa/Makefile.in
new file mode 100644
index 0000000..be4a02b
--- /dev/null
+++ b/qa/Makefile.in
@@ -0,0 +1,704 @@
+# 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
+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 =
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ distdir distdir-am
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+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@
+SUBDIRS = coccinelle
+EXTRA_DIST = wirefuzz.pl sock_to_gzip_file.py drmemory.suppress
+all: all-recursive
+
+.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/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu qa/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
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+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
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(am__recursive_targets) install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+ check-am clean clean-generic clean-libtool cscopelist-am ctags \
+ ctags-am distclean distclean-generic distclean-libtool \
+ distclean-tags 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 \
+ installdirs-am maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am tags tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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/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)
diff --git a/qa/drmemory.suppress b/qa/drmemory.suppress
new file mode 100644
index 0000000..2527bd6
--- /dev/null
+++ b/qa/drmemory.suppress
@@ -0,0 +1,111 @@
+UNADDRESSABLE ACCESS
+name=magic issue, not important
+libc.so.6!__strnlen_sse2
+libc.so.6!_IO_vfprintf_internal
+libc.so.6!__GI___vasprintf_chk
+libc.so.6!__asprintf_chk
+libmagic.so.1!?
+libmagic.so.1!file_apprentice
+libmagic.so.1!magic_load
+suricata!main
+
+LEAK
+name=useless warning, likely DrMemory bug
+*
+libpcre.so.3!pcre_get_substring
+
+LEAK
+name=libmagic minor leak 1
+libmagic.so.1!?
+libmagic.so.1!?
+libmagic.so.1!magic_load
+suricata!MagicInit
+
+LEAK
+name=libmagic minor leak 2
+libmagic.so.1!?
+libmagic.so.1!magic_load
+suricata!MagicInit
+
+UNINITIALIZED READ
+name=Hyperscan false positives due to DrMemory limitations 1
+...
+libhs.so.*!hs_compile_ext_multi
+*
+
+UNINITIALIZED READ
+name=Hyperscan false positives due to DrMemory limitations 2
+...
+libhs.so.*!hs_compile
+*
+
+UNINITIALIZED READ
+name=Hyperscan false positive
+...
+libhs.so.*!*_hs_scan
+suricata!SCHSSearch
+*
+
+UNINITIALIZED READ
+name=Hyperscan false positive
+...
+libhs.so.*!*_hs_scan
+suricata!HSScan
+*
+
+UNADDRESSABLE ACCESS
+name=Hyperscan false positive
+...
+libhs.so.*!*_hs_scan
+suricata!SCHSSearch
+*
+
+UNADDRESSABLE ACCESS
+name=Hyperscan false positive
+...
+libhs.so.*!*_hs_scan
+suricata!HSScan
+*
+
+UNINITIALIZED READ
+name=Hyperscan false positive
+...
+libhs.so.*!hs_alloc_scratch
+suricata!HSBuildDatabase
+*
+
+UNINITIALIZED READ
+name=Hyperscan false positive
+...
+libhs.so.*!hs_alloc_scratch
+suricata!SCHSPreparePatterns
+*
+
+WARNING
+name=Prefetch warnings 1
+...
+libhs.so.*!hs_scan
+suricata!SCHSSearch
+*
+
+WARNING
+name=Prefetch warnings 3
+...
+libhs.so.*!hs_scan
+suricata!HSScan
+*
+
+WARNING
+name=Prefetch warnings 4
+...
+libhs.so.*!*hs_scan
+suricata!SCHSSearch
+*
+
+WARNING
+name=Prefetch warnings 5
+...
+libhs.so.*!*hs_scan
+suricata!HSScan
+*
+
diff --git a/qa/sock_to_gzip_file.py b/qa/sock_to_gzip_file.py
new file mode 100755
index 0000000..4c51782
--- /dev/null
+++ b/qa/sock_to_gzip_file.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+#I love the python Power Glove. It's so bad!
+#Usage: sudo -u suricata ./sock_to_gzip_file.py --output-file="http.log.gz" --listen-sock="http.log.sock"
+
+import socket,os
+import gzip
+import sys
+from optparse import OptionParser
+
+if __name__ == "__main__":
+ parser = OptionParser()
+ #Path to the socket
+ parser.add_option("--listen-sock", dest="lsock", type="string", help="Path to the socket we will listen on.")
+ #Path to gzip file we will write
+ parser.add_option("--output-file", dest="output", type="string", help="Path to file name to output gzip file we will write to.")
+
+ #parse the opts
+ (options, args) = parser.parse_args()
+
+ options.usage = "example: sudo -u suricata ./sock_to_gzip_file.py --output-file=\"http.log.gz\" --listen-sock=\"http.log.sock\"\n"
+ #Open the output file
+ if options.output:
+ try:
+ f = gzip.open(options.output, 'wb')
+ except Exception,e:
+ print("Error: could not open output file %s:\n%s\n", options.output, e)
+ sys.exit(-1)
+ else:
+ print("Error: --output-file option required and was not specified\n%s" % (options.usage))
+ sys.exit(-1)
+
+ #Open our socket and bind
+ if options.lsock:
+ if os.path.exists(options.lsock):
+ try:
+ os.remove(options.lsock)
+ except OSError:
+ pass
+ try:
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.bind(options.lsock)
+ s.listen(1)
+ conn, addr = s.accept()
+ except Exception,e:
+ print("Error: Failed to bind socket %s\n%s\n", options.lsock, e)
+ sys.exit(-1)
+ else:
+ print("Error: --listen-sock option required and was not specified\n%s" % (options.usage))
+ sys.exit(-1)
+
+ #Read data from the socket and write to the file
+ while 1:
+ data = conn.recv(1024)
+ if not data: break
+ f.write(data)
+ conn.close()
+ f.close()
diff --git a/qa/wirefuzz.pl b/qa/wirefuzz.pl
new file mode 100755
index 0000000..759cd9a
--- /dev/null
+++ b/qa/wirefuzz.pl
@@ -0,0 +1,709 @@
+#!/usr/bin/perl -w
+#Author:William Metcalf <william.metcalf@gmail.com>
+#File:wirefuzz.pl
+
+#Copyright (C) 2010-2015 Open Information Security Foundation
+
+#You can copy, redistribute or modify this Program under the terms of
+#the GNU General Public License version 2 as published by the Free
+#Software Foundation.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#version 2 along with this program; if not, write to the Free Software
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#02110-1301, USA.
+
+#This script is useful if you want to fuzz and or otherwise try to make suricata explode during decoding/proto parsing using saved pcaps.
+#It is simply a reimplementation of the technique described here, hence the name:
+#http://wiki.wireshark.org/FuzzTesting
+#
+#Options for getting the required perl modules:
+#Ubuntu 9.10
+#sudo apt-get install libdevel-gdb-perl libcapture-tiny-perl
+#
+#RedHatES/CentOS 5
+#yum -y install cpanspec perl-Module-Build
+#cpanspec --packager OISF -v -s --follow Capture::Tiny
+#cpanspec --packager OISF -v -s --follow Devel::GDB
+#rpmbuild --rebuild *.src.rpm
+#rpm -ivh /usr/src/redhat/RPMS/noarch/perl-Devel-GDB*.rpm
+#rpm -ivh /usr/src/redhat/RPMS/noarch/perl-Capture-Tiny*.rpm
+#
+#Fedora Core 12
+#yum -y install perl-Capture-Tiny perl-Devel-GDB
+#
+#Other debian based versions, try the Ubuntu instructions if this doesn't work try the following.
+#sudo apt-get install dh-make-perl
+#mkdir fuzzmodules && cd fuzzmodules
+#dh-make-perl --cpan Devel-GDB --build
+#dh-make-perl --cpan Capture-Tiny --build
+#sudo dpkg -i *.deb
+
+#TODO: Figure out a better way to deal with signal handling.
+#TODO: Try to determine flow/stream that caused segv by extracting from the bt and extract it from the pcap.
+#TODO: E-mail notification on segv?
+#TODO: Parse Valgrind output and alert on errors
+
+use strict;
+use warnings;
+use Capture::Tiny 'capture';
+use List::Util 'shuffle';
+use Devel::GDB;
+use File::Find;
+use Getopt::Long qw(:config no_ignore_case);
+use File::Basename;
+
+#globals
+my %config;
+my @tmpfiles;
+my @files;
+my $suricatabin;
+my $loopnum;
+my $loopnum_per_file = 0;
+my $rules;
+my $rules_exclusive = 0;
+my $logdir;
+my $configfile;
+my $editeratio;
+my $valgrindopt;
+my $shuffle;
+my $useltsuri;
+my $ltsuribin;
+my $core_dump;
+my $excluderegex;
+my %excludefuzz;
+my $timestamp;
+my $keeplogs;
+my $file_was_fuzzed = 0;
+
+Getopt::Long::Configure("prefix_pattern=(-|--)");
+GetOptions( \%config, qw(n=s N=s r=s c=s e=s v=s p=s l=s s=s S=s x=s k y z=s q h help) );
+
+&parseopts();
+
+#Parse the options
+sub parseopts {
+
+ #display help if asked
+ if ( $config{h} || $config{help} ) {
+ &printhelp();
+ }
+
+ #filemask of pcaps to read?
+ if ( $config{r} ) {
+ @tmpfiles = <$config{r}>;
+ if(@tmpfiles eq 0){
+ print "parseopts: Pcap filemask was invalid we couldn't find any matching files\n";
+ exit(1);
+ } else {
+ #escapes for filenames
+ foreach my $file (@tmpfiles) {
+ $file =~ s/\(/\\(/g;
+ $file =~ s/\)/\\)/g;
+ $file =~ s/\&/\\&/g;
+ }
+ }
+ }
+ else {
+ print "parseopts: Pcap filemask not specified or doesn't exist\n";
+ &printhelp();
+ }
+
+ #filemask do we have a path to suricata bin?
+ if ( $config{p} && -e $config{p} ) {
+ $suricatabin = $config{p};
+
+ #do wrapper script detection lt-suricata won't be created until first run but .libs/suricata should exist.
+ if ( -T $suricatabin ) {
+ open my $in, '<', $suricatabin or die "Can't read old file: $!";
+ while (<$in>) {
+ if ( $_ =~
+ m/suricata \- temporary wrapper script for \.libs\/suricata/
+ )
+ {
+ print "parseopts: suricata bin file appears to be a wrapper script going to try to find the real bin for gdb.\n";
+ my $tmpdirname = dirname $suricatabin;
+ my $tmpltsuriname = $tmpdirname . "/.libs/suricata";
+ if ( -e $tmpltsuriname && -B $tmpltsuriname ) {
+ $ltsuribin = $tmpltsuriname;
+ print "parseopts: telling gdb to use " . $ltsuribin . "\n";
+ $useltsuri = "yes";
+ }
+ last;
+ }
+ }
+ close $in;
+ }
+ elsif ( -B $suricatabin ) {
+ if ( ! $config{q} ) {
+ print "parseopts: suricata bin file checks out\n";
+ }
+ }
+ else {
+ print "parseopts: suricata bin file is not a text or a bin exiting.\n";
+ exit(1);
+ }
+ }
+ else {
+ print "parseopts: Path to suricata bin not provided or doesn't exist\n";
+ &printhelp();
+ }
+
+ if ( $config{n} && $config{N} ) {
+ print "ERROR: can't mix -n and -N\n";
+ exit(1);
+ }
+
+ #number of times to loop
+ if ( $config{n} ) {
+ $loopnum = $config{n};
+ $loopnum_per_file = 1;
+ print "parseopts: looping through the pcaps " . $loopnum . " times or until we have an error\n";
+ }
+ else {
+ $loopnum = "infinity";
+ }
+
+ if ( $config{N} ) {
+ $loopnum = $config{N};
+ print "parseopts: looping through the pcaps " . $loopnum . " times or until we have an error\n";
+ }
+ else {
+ $loopnum = "infinity";
+ }
+
+ if ( $loopnum == "infinity") {
+ print "parseopts: looping through the pcaps forever or until we have an error\n";
+ }
+
+ #rules file do we have a path and does it exist
+ if ( $config{s} && -e $config{s} ) {
+ $rules = $config{s};
+ print "parseopts: telling suricata to use rules file " . $rules . "\n";
+ }
+ else {
+ print("parseopts: rules file not specified or doesn't exist\n");
+ }
+
+ # exclusive rules file: do we have a path and does it exist
+ if ( $config{S} && -e $config{S} ) {
+ $rules = $config{S};
+ $rules_exclusive = 1;
+ print "parseopts: telling suricata to use rules file exclusively " . $rules . "\n";
+ }
+ else {
+ print("parseopts: rules file not specified or doesn't exist\n");
+ }
+
+ #log dir does it exist
+ if ( $config{l} && -e $config{l} ) {
+ $logdir = $config{l} . "/";
+ print "parseopts: using log dir " . $logdir . "\n";
+ }
+ else {
+ $logdir = "./";
+ }
+
+ #config file do we have a path and does it exist
+ if ( $config{c} && -e $config{c} ) {
+ $configfile = $config{c};
+ print "parseopts: telling suricata to use the config file " . $configfile . "\n";
+ }
+ else {
+ print "parseopts: config file not specified or doesn't exist\n";
+ &printhelp();
+ }
+
+ #% chance that a byte will be modified.
+ if ( $config{e} ) {
+
+ #valid range?
+ my $tmperatio = $config{e} * 100;
+ if ( $tmperatio <= 100 && $tmperatio >= 0 ) {
+ $editeratio = $config{e};
+ print "parseopts: using error ratio " . $editeratio . "\n";
+ }
+ else {
+ print "parseopts: error ratio specified but outside of range. Valid range is 0.00-1.0\n";
+ exit(1);
+ }
+ }
+ else {
+ print("parseopts: not going to fuzz pcap(s)\n");
+ }
+
+ #parse the valgrind opts
+ if ( $config{v} ) {
+ if ( $config{v} =~ /^(memcheck|drd|helgrind|callgrind)$/ ) {
+ $valgrindopt = $config{v};
+ print "parseopts: using valgrind opt " . $valgrindopt . "\n";
+ }
+ else {
+ print "invalid valgrind opt " . $valgrindopt . "\n";
+ }
+ }
+
+ #shuffle the array if we are starting multiple fuzzers at once. GO-GO gadget shuffle
+ if ( $config{y} ) {
+ print "parseopts: going to shuffle the array\n";
+ $shuffle = "yes";
+ }
+
+ #keep logs instead of removing them after each run
+ if ( $config{k} ) {
+ print "parseopts: going to keep logs instead of removing them\n";
+ $keeplogs = "yes";
+ }
+ else {
+ $keeplogs = "no";
+ }
+
+ #we want to process some files but not fuzz them add them to a hash and check it later
+ if ( $config{z} ) {
+ print "will process but not fuzz files that match regex of " . $config{z} . "\n";
+ $excluderegex = $config{z};
+
+ my $tmpfilepos = 0;
+ while ($tmpfilepos <= $#tmpfiles) {
+ if ($tmpfiles[$tmpfilepos] =~ m/$excluderegex/) {
+ print "adding " . $tmpfiles[$tmpfilepos] . " to fuzz_exclude_hash because it matches our regex\n";
+ $excludefuzz{$tmpfiles[$tmpfilepos]} = 1;
+ }
+ $tmpfilepos++
+ }
+ }
+
+ #maybe we want to exclude a file based on some regex so we can restart the fuzzer after an error
+ #and not have to worry about hitting the same file.
+ if ( $config{x} ) {
+ print "excluding files that match regex of " . $config{x} . "\n";
+ $excluderegex = $config{x};
+
+ my $tmpfilepos = 0;
+ while ($tmpfilepos <= $#tmpfiles) {
+ if ($tmpfiles[$tmpfilepos] =~ m/$excluderegex/) {
+ print "removing " . $tmpfiles[$tmpfilepos] . " because it matches our exclude regex\n";
+ splice(@tmpfiles, $tmpfilepos, 1);
+ }
+ else {
+ $tmpfilepos++
+ }
+ }
+ }
+
+ if ( ! $config{q} ) {
+ print "******************Initialization Complete**********************\n";
+ }
+ return;
+
+}
+
+sub printhelp {
+ print "
+ -h or help <this output>
+ -r=<filemask for pcaps to read>
+ -n=<(optional) number of iterations or if not specified will run until error>
+ -N=<(optional) number of iterations of all files in the test set>
+ -s=<(optional) path to ids rules file will be passed as -s to suricata>
+ -S=<(optional) path to ids rules file will be passed as -S to suricata>
+ -e=<(optional) editcap error ratio to introduce if not specified will not fuzz. Valid range for this is 0.00 - 1.0>
+ -p=<path to the suricata bin>
+ -l=<(optional) log dir for output if not specified will use current directory.>
+ -v=<(optional) (memcheck|drd|helgrind|callgrind) will run the command through one of the specified valgrind tools.>
+ -x=<(optional) regex for excluding certain files incase something blows up but we want to continue fuzzing .>
+ -z=<(optional) regex for excluding certain files from fuzzing but still process them note: the original files will be processed and not removed.>
+ -y <shuffle the array, this is useful if running multiple instances of this script.>
+ -k <will keep alert-debug.log fast.log http.log and stats.log instead of removing them at the end of each run.>
+ Example usage:
+ First thing to do is download and build suricata from git with -O0 so vars don't get optimized out. See the example below:
+ git clone git://phalanx.openinfosecfoundation.org/oisf.git suricatafuzz1 && cd suricatafuzz1 && ./autogen.sh && CFLAGS=\"-g -O0\" ./configure && make
+
+ Second thing to do is to edit suricata.yaml to fit your environment.
+
+ Third go ahead and run the script.
+
+ In the example below the script will loop forever until an error is encountered will behave in the following way.
+ 1.-r Process all pcaps in subdirectories of /home/somepath/pcaps/
+ 2.-s Tell suricata to use the rules file /home/somepath/current-all.rules
+ 3.-y Shuffle the array of pcaps this is useful if running multiple instances of this script.
+ 4.-c Tell suricata to use the suricata.yaml in the current dir.
+ 6.-e Tell editcap to introduce a 2% error ratio, i.e. there is a 2% chance that a byte will be fuzzed see http://wiki.wireshark.org/FuzzTesting for more info.
+ 7.-p Use src/suricata as our suricata bin file. The script will determine if the argument passed is a bin file or a txt wrapper and will adjust accordingly.
+
+ /usr/bin/wirefuzz.pl -r=/home/somepath/pcaps/*/* -s=/home/somepath/current-all.rules -y -c=suricata.yaml -e=0.02 -p src/suricata
+
+ If an error is encountered a file named <fuzzedfile>ERR.txt will be created in the log dir (current dir in this example) that will contain output from stderr,stdout, and gdb.
+
+ Take a look at the opts make it work for you environment and from the OISF QA team thanks for helping us make our meerkat fuzzier! ;-)\n";
+ exit;
+}
+
+my $logfile = $logdir . "wirefuzzlog.txt";
+open( LOGFILE, ">>$logfile" )
+|| die( print "error: Could not open logfile! $logfile\n" );
+
+my $successcnt = 0;
+while ( $successcnt < $loopnum ) {
+ if ( defined $shuffle ) {
+ @files = shuffle(@tmpfiles);
+ }
+ else {
+ @files = @tmpfiles;
+ }
+
+ foreach my $file (@files) {
+ my $file_was_fuzzed = 0;
+ #split out the path from the filename
+ my $filedir = dirname $file;
+ my $filename = basename $file;
+ my ( $fuzzedfile, $editcapcmd, $editcapout, $editcaperr, $editcapexit,
+ $editcap_sys_signal, $editcap_sys_coredump );
+ my ( $fuzzedfiledir, $fuzzedfilename, $fullcmd, $out, $err, $exit,
+ $suricata_sys_signal, $suricata_sys_coredump, $report);
+ if ( ! $config{q} ) {
+ print "Going to work with file: $file\n";
+ }
+ my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
+ localtime(time);
+ $timestamp = sprintf "%4d-%02d-%02d-%02d-%02d-%02d", $year + 1900,
+ $mon + 1, $mday, $hour, $min, $sec;
+ if ( defined $editeratio and !exists $excludefuzz{$file}) {
+ $file_was_fuzzed = 1;
+ $fuzzedfile = $logdir . $filename . "-fuzz-" . $timestamp;
+ $editcapcmd =
+ "editcap -E " . $editeratio . " " . $file . " " . $fuzzedfile;
+ if ( ! $config{q} ) {
+ print( "editcap: " . $editcapcmd . "\n" );
+ }
+ ( $editcapout, $editcaperr ) = capture {
+ system $editcapcmd;
+ $editcapexit = $? >> 8;
+ $editcap_sys_signal = $? & 127;
+ $editcap_sys_coredump = $? & 128;
+ };
+ if ( $editcapexit ne 0 ) {
+
+ #this could still cause us to loop forever if all pcaps are bad but it's better than nothing.
+ if ( @files < 2 ) {
+ print "editcap: had an error and this was our only pcap:" . $editcaperr . "\n";
+ exit(1);
+ }
+ else {
+ print "editcap: had an error going to the next pcap:" . $editcaperr . "\n";
+ next;
+ }
+ }
+ elsif ( $editcap_sys_signal eq 2 ) {
+ print "editcap: system() got a ctl+c we are bailing as well\n";
+ exit(1);
+
+ }
+ elsif ( ! $config{q} ) {
+ print("editcap: ran successfully\n");
+ print
+ "******************Editcap Complete**********************\n";
+ }
+ }
+ else {
+ $fuzzedfile = $file;
+ }
+
+ #split out the path from the filename
+ $fuzzedfiledir = dirname $fuzzedfile;
+ $fuzzedfilename = basename $fuzzedfile;
+
+ $fullcmd = "ulimit -c unlimited; ";
+
+ if ( defined $valgrindopt ) {
+ if ( $valgrindopt eq "memcheck" ) {
+ $fullcmd =
+ $fullcmd
+ . "valgrind -v --log-file="
+ . $logdir
+ . $fuzzedfilename
+ . $timestamp
+ . "-memcheck-vg.log ";
+ }
+ elsif ( $valgrindopt eq "drd" ) {
+ $fullcmd =
+ $fullcmd
+ . "valgrind --tool=drd --var-info=yes -v --log-file="
+ . $logdir
+ . $fuzzedfilename
+ . $timestamp
+ . "-drd-vg.log ";
+ }
+ elsif ( $valgrindopt eq "helgrind" ) {
+ $fullcmd =
+ $fullcmd
+ . "valgrind --tool=helgrind -v --log-file="
+ . $logdir
+ . $fuzzedfilename
+ . $timestamp
+ . "-helgrind-vg.log ";
+ }
+ elsif ( $valgrindopt eq "callgrind" ) {
+ $fullcmd =
+ $fullcmd
+ . "valgrind --tool=callgrind -v --callgrind-out-file="
+ . $logdir
+ . $fuzzedfilename
+ . $timestamp
+ . "-callgrind-vg.log ";
+ }
+ }
+
+ $fullcmd =
+ $fullcmd
+ . $suricatabin . " -c "
+ . $configfile . " -r "
+ . $fuzzedfile . " -l "
+ . $logdir;
+ if ( defined $rules ) {
+ if ($rules_exclusive == 1) {
+ $fullcmd = $fullcmd . " -S " . $rules;
+ } else {
+ $fullcmd = $fullcmd . " -s " . $rules;
+ }
+ }
+ if ( ! $config{q} ) {
+ print "suricata: $fullcmd \n";
+ }
+ my $starttime = time();
+ ( $out, $err ) = capture {
+ system $fullcmd;
+ $exit = $? >> 8;
+ $suricata_sys_signal = $? & 127;
+ $suricata_sys_coredump = $? & 128;
+ };
+
+ my $stoptime = time();
+ my $timetotal = $stoptime - $starttime;
+ print LOGFILE $fullcmd . ","
+ . $timetotal . ","
+ . $exit . ","
+ . $suricata_sys_signal . ","
+ . $suricata_sys_coredump . "\n";
+ if ( ! $config{q} ) {
+ print "suricata: exit value $exit\n";
+ }
+
+ if ( $exit ne 0 ) {
+ my $knownerr = 0;
+
+ #fuzzer generated some random link type we can't deal with
+ if ( $err =~
+ /datalink type \d+ not \(yet\) supported in module PcapFile\./ )
+ {
+ print "suricata: we matched a known error going to the next file\n";
+ $knownerr = 1;
+ }
+ elsif ( $err =~
+ /invalid interface capture length/ )
+ {
+ print "suricata: we matched a known error going to the next file\n";
+ $knownerr = 1;
+ }
+ if ( $knownerr eq 1 ) {
+ if ($loopnum_per_file == 1) {
+ $successcnt++;
+ }
+ print "suricata: we have run with success " . $successcnt . " times\n";
+ if( $keeplogs eq "yes" ) {
+ &keep_logs($fuzzedfilename);
+ $report = $logdir . $fuzzedfilename . "-OUT.txt";
+ &generate_report($report, $fullcmd, $out, $err, $exit, "none");
+ }
+ &clean_logs($fuzzedfilename,$file_was_fuzzed);
+ }
+ else {
+ print "suricata: $fullcmd \n";
+ print "suricata: exit value $exit\n";
+ my $report = $logdir . $fuzzedfilename . "-ERR.txt";
+
+ &process_core_dump();
+ if ($core_dump) {
+ print "core dump \n $core_dump";
+ system( "mv "
+ . $ENV{'PWD'}
+ . "/core* "
+ . $logdir
+ . $fuzzedfilename
+ . ".core" );
+ &generate_report($report, $fullcmd, $out, $err, $exit, $core_dump);
+ }else{
+ &generate_report($report, $fullcmd, $out, $err, $exit, "none");
+ }
+ exit(1);
+ }
+ }
+ elsif ( $suricata_sys_signal eq 2 ) {
+ print "suricata: system() got a ctl+c we are bailing as well\n";
+ if( $keeplogs eq "yes" ) {
+ &keep_logs($fuzzedfilename);
+ }
+ &clean_logs($fuzzedfilename,$file_was_fuzzed);
+ exit;
+ }
+ else {
+ if ($loopnum_per_file == 1) {
+ $successcnt++;
+ }
+
+ if ( ! $config{q} ) {
+ print "suricata: we have run with success " . $successcnt . " times\n";
+ print "******************Suricata Complete**********************\n";
+ }
+ if( $keeplogs eq "yes" ) {
+ &keep_logs($fuzzedfilename);
+ $report = $logdir . $fuzzedfilename . "-OUT.txt";
+ &generate_report($report, $fullcmd, $out, $err, $exit, "none");
+ }
+ &clean_logs($fuzzedfilename,$file_was_fuzzed);
+ if ( ! $config{q} ) {
+ print "******************Next Pcap or Exit *******************\n";
+ }
+ }
+
+ if ($successcnt >= $loopnum) {
+ last;
+ }
+ }
+ if ($loopnum_per_file == 0) {
+ $successcnt++;
+ }
+ if ($successcnt >= $loopnum) {
+ last;
+ }
+}
+
+sub process_core_dump {
+ my $gdbbin;
+ my $gdb = new Devel::GDB();
+ my $coremask = $ENV{'PWD'} . "/core*";
+ my @coredumps = <${coremask}>;
+ if (@coredumps eq 1 ) {
+ my $corefile = $coredumps[0];
+ print "gdb: core dump found $corefile processing with";
+ if ( $useltsuri eq "yes" ) {
+ $gdbbin = $ltsuribin;
+ }
+ else {
+ $gdbbin = $suricatabin;
+ }
+ print " the following bin file" . $gdbbin . "\n";
+ $core_dump .= join '',
+ $gdb->get("file $gdbbin"), $gdb->get("core $corefile"),
+ $gdb->get('info threads'), $gdb->get('thread apply all bt full');
+ print "gdb: core dump \n $core_dump";
+
+ }
+ elsif ( @coredumps > 1 ) {
+ print "gdb: multiple core dumps, please clear all core dumps and try the test again. We found:\n";
+ foreach my $corefile (@coredumps) {
+ print $corefile . "\n";
+ }
+ }
+ else {
+ print "gdb: no coredumps found returning.\n";
+ print @coredumps;
+ print " $#coredumps" . "\n";
+ }
+ print "******************GDB Complete**********************\n";
+ return;
+}
+
+sub clean_logs {
+ my $deleteme = shift;
+ my $file_was_fuzzed = shift;
+ my $deletemerge = $logdir . $deleteme;
+ my $rmcmd;
+ if ( defined $editeratio and $file_was_fuzzed) {
+ if ( unlink($deletemerge) == 1 ) {
+ if ( ! $config{q} ) {
+ print "clean_logs: " . $deletemerge . " deleted successfully.\n";
+ }
+ }
+ else {
+ print "clean_logs: error " . $deletemerge . " was not deleted. You may have to delete the file manually.\n";
+ }
+ }
+
+ if ( defined $valgrindopt ) {
+ #uncomment the following lines if you want to remove valgrind logs
+ #$rmcmd = "rm -f " . $deletemerge . "*vg.log";
+ #print( "running " . $rmcmd . "\n" );
+ #system("$rmcmd");
+ }
+
+ foreach my $file (glob "$logdir/*.log $logdir/*.json") {
+ #print $file . "\n";
+ if (unlink($file) <= 0) {
+ print "clean_logs: failed to delete log file $file\n";
+ }
+ }
+
+ return;
+}
+
+sub keep_logs {
+ my $saveme = shift;
+ unless(defined($editeratio) || $loopnum eq '1'){
+ my $saveme = $saveme . "-" . $timestamp;
+ }
+ my $savecmd;
+
+ if (-e $logdir . "alert-debug.log"){
+ $savecmd = "mv -f " . $logdir
+ . "alert-debug.log "
+ . $logdir
+ . $saveme
+ . "-alert-debug.log";
+ system($savecmd);
+ }
+ if (-e $logdir . "fast.log"){
+ $savecmd = "mv -f " . $logdir
+ . "fast.log "
+ . $logdir
+ . $saveme
+ . "-fast.log";
+ system($savecmd);
+ }
+ if (-e $logdir . "http.log"){
+ $savecmd = "mv -f " . $logdir
+ . "http.log "
+ . $logdir
+ . $saveme
+ . "-http.log";
+ system($savecmd);
+ }
+ if (-e $logdir . "stats.log"){
+ $savecmd = "mv -f " . $logdir
+ . "stats.log "
+ . $logdir
+ . $saveme
+ . "-stats.log";
+ system($savecmd);
+ }
+ print "******************Log Move Complete**********************\n";
+ return;
+}
+
+sub generate_report {
+ my ($report, $fullcmd, $stdout, $stderr, $exit, $coredump) = ($_[0], $_[1], $_[2], $_[3], $_[4], $_[5]);
+
+ open( REPORT, ">$report" ) || ( print "Could not open report file! $report\n" );
+ print REPORT "COMMAND:$fullcmd\n";
+ print REPORT "EXITVAL:$exit\n";
+ print REPORT "STDERR:$stderr\n";
+ print REPORT "STDOUT:$stdout\n";
+ if($coredump ne "none"){
+ print REPORT "COREDUMP:$coredump\n";
+ }
+ close(REPORT);
+}