Make sure tls-events is part of the dist

Added it to Makefile.am so it will be part of the dist created by
make distcheck.
pcap/afpacket: update counters at exit

In really short Suricata runtimes the capture counters would not
be updated. This patch does a force update at the end of the
capture loops in pcap and af-packet.
configure: fix typo in libjansson warning message
htp: don't assume HTPCallbackRequestLine is the first callback

By assuming that HTPCallbackRequestLine would always be run first,
an memory leak was introduced. It would not check if user data already
existed in the tx, causing it to overwrite the user data pointer is
it already existed.

Bug #1092.
smtp: don't read uninitialized value

If a reply would be seen before a command, a read of a uninitialized
value could happen.

This patch adds a check for this.

Bug #1089.
tls: fix uninitialized var use

errcode wasn't initialized and in some code paths it remained
uninitialized, leading to us evaluating this uninitialized value.

Bug #1091
ftp: fix memory leak

db pointers in both directions were not freed. This patch frees them
in the state free function.

Bug #1090
output-json: fix minor memory leak on error

If the json file couldn't be opened, a minor memory leak would occur.

Coverity 1166039
rule reload: fix unitialized memory access on error

Coverity 709220
htp: fix pointer check logic

Don't check pointer after it has already been used.

Coverity 1047545
Minor cleanups

Remove useless checks: coverity 1038130, 1038131, 1038132
Small other fixes: coverity 1164817
byte_extract/test/jump: fix coverity issues

During keyword setup there was a path that in theory could lead to
indexing an array with a negative int.

Coverity 992695, 400605, 400604
fast-pattern: fix error check in keyword setup

Check the right variable. Coverity 1038096
isdataat: fix coverity issue

During keyword setup there was a path that in theory could lead to
indexing an array with a negative int.

Coverity 400608
Only update mPipe stats occasionally around the packet loop.

Check for termination or stats update only once every 10,000 times
around the mPipe packet processing loop, to reduce locking.
icmpv6: Fix Coverity warnings on ND_* types

This patch fixes:
** CID 1187544:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 268 in DecodeICMPV6()

** CID 1187545:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 270 in DecodeICMPV6()

** CID 1187546:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 272 in DecodeICMPV6()

** CID 1187547:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 274 in DecodeICMPV6()

It duplicates the logic instead of adding 'fall through' statements
as the debug statements were wrong and confusing. For ND_REDIRECT
all 5 ND_* types would have been printed.
commandline parsing: check optarg ptr before using it

Fixes:
** CID 1075221:  Dereference after null check  (FORWARD_NULL)
/src/suricata.c: 1344 in ParseCommandLine()

The reason it gave this warning is that in other paths using optarg
there was a check, so the checker assumed optarg can be NULL.
stream-tcp: fix error handling in segment pool

When TcpSegmentPoolInit fails (e.g. because of a too low memcap),
it would free the segment. However, the segment memory is managed
by the Pool API, which would also free the same memory location.
This patch fixes that.

Also, memset the structure before any checks are done, as the segment
memory is passed to TcpSegmentPoolCleanup in case of error as well.

Bug #1108
stream-tcp: proper error if segment pool init fails

Until now a PoolInit failure for the segment pools would result in
an abort() through BUG_ON(). This patch adds a proper error message,
then exits.

Bug #1108.
af-packet: fix livedev packets counter

Packets counter is incremented in AFPDumpCounters and it was
also incremented during packet reading. The result was a value
that is twice the expected result.

Spotted-by: Victor Julien <victor@inliniac.net>