]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
11 years agoFix compiler warning about uninitialized variable in mpipe. 1159/head
Ken Steele [Tue, 12 Aug 2014 23:57:41 +0000 (19:57 -0400)] 
Fix compiler warning about uninitialized variable in mpipe.

11 years agotile: silence harmless cc warnings
Victor Julien [Wed, 8 Oct 2014 10:59:39 +0000 (12:59 +0200)] 
tile: silence harmless cc warnings

11 years agolua: improve configure checks
Victor Julien [Mon, 11 Aug 2014 12:14:59 +0000 (14:14 +0200)] 
lua: improve configure checks

The base 'lua' library has different names on different OS' and even
Linux distro's. Instead of selecting the proper one, we now just try
all. This way no OS/distro specific knowledge about the name is needed.

11 years agotcp session reuse: reset detect state
Victor Julien [Tue, 7 Oct 2014 09:27:54 +0000 (11:27 +0200)] 
tcp session reuse: reset detect state

Reset the detect state on TCP session reuse. We reset the app layer,
so we need to reset the stateful detection as well.

11 years agodetect state: always lock de_state_m
Victor Julien [Tue, 7 Oct 2014 09:25:25 +0000 (11:25 +0200)] 
detect state: always lock de_state_m

Always lock the de_state_m on access, also at flow recycle or
cleanup.

11 years agofilestore: fix parsing bug 1149/head 1150/head
Victor Julien [Tue, 30 Sep 2014 07:56:41 +0000 (09:56 +0200)] 
filestore: fix parsing bug

Filestore keyword can have options or no options, and the parser
was enforcing the NOOPT flag too strictly.

Bug #1288

11 years agoUpdate changelog for 2.0.4 suricata-2.0.4
Victor Julien [Tue, 23 Sep 2014 10:16:15 +0000 (12:16 +0200)] 
Update changelog for 2.0.4

11 years agossh: convert error message to debug statement
Victor Julien [Thu, 18 Sep 2014 08:13:18 +0000 (10:13 +0200)] 
ssh: convert error message to debug statement

Don't print errors based on traffic issues.

11 years agoapp-layer-ssh: fix banner parser
Eric Leblond [Fri, 12 Sep 2014 08:02:12 +0000 (10:02 +0200)] 
app-layer-ssh: fix banner parser

Carefully crafted SSH banner could result in parser error.

CVE 2014-6603

Signed-off-by: Eric Leblond <eric@regit.org>
Reported-By: Steffen Bauch
11 years agoipv6: RH extension header parsing issue
Victor Julien [Wed, 17 Sep 2014 12:26:27 +0000 (14:26 +0200)] 
ipv6: RH extension header parsing issue

A logic error in the IPv6 Routing header parsing caused accidental
updating of the original packet buffer. The calculated extension
header lenght was set to the length field of the routing header,
causing it to be wrong.

This has 2 consequences:

1. defrag failure. As the now modified payload was used in defrag,
the decoding of the reassembled packet now contained a broken length
field for the routing header. This would lead to decoding failure.

The potential here is evasion, although it would trigger:
[1:2200014:1] SURICATA IPv6 truncated extension header

2. in IPS mode, especially the AF_PACKET mode, the modified and now
broken packet would be transmitted on the wire. It's likely that
end hosts and/or routers would reject this packet.

NFQ based IPS mode would be less affected, as it 'verdicts' based on
the packet handle. In case of replacing the packet (replace keyword
or stream normalization) it could broadcast the bad packet.

Additionally, the RH Type 0 address parsing was also broken. It too
would modify the original packet. As the result of this code was not
used anywhere else in the engine, this code is now disabled.

Reported-By: Rafael Schaefer <rschaefer@ernw.de>
11 years agoaf-packet: check pointers before use
Victor Julien [Mon, 22 Sep 2014 15:33:40 +0000 (17:33 +0200)] 
af-packet: check pointers before use

11 years agoaf-packet: force suricata in IPS mode when needed
Eric Leblond [Fri, 19 Sep 2014 14:54:00 +0000 (16:54 +0200)] 
af-packet: force suricata in IPS mode when needed

AF_PACKET is not setting the engine mode to IPS when some
interfaces are peered and use IPS mode. This is due to the
fact, it is possible to peer 2 interfaces and run an IPS on
them and have a third one that is running in normal IDS mode.

In fact this choice is the bad one as unwanted side effect is
that there is no drop log and that stream inline is not used.

To fix that, this patch puts suricata in IPS mode as soon as
there is two interfaces in IPS mode. And it displays a error
message to warn user that the accuracy of detection on IDS only
interfaces will be low.

11 years agorule parser: set flag for optionless keywords 1129/head
Victor Julien [Fri, 19 Sep 2014 11:39:37 +0000 (13:39 +0200)] 
rule parser: set flag for optionless keywords

If a keyword doesn't have an argument, it should set the SIGMATCH_NOOPT
flag so the parser knows.

11 years agorule parser: fix crashing on malformed options
Victor Julien [Fri, 19 Sep 2014 11:38:47 +0000 (13:38 +0200)] 
rule parser: fix crashing on malformed options

Fix crashing on malformed rule options like 'rev;1;'.

Bug 1254.

11 years agolua: fix http.request_line 1127/head
Victor Julien [Thu, 18 Sep 2014 15:02:47 +0000 (17:02 +0200)] 
lua: fix http.request_line

The request line scripts were added to the AMATCH list. However, there
is not AppLayerMatch function defined for lua scripts. So scripts
would not run.

This patch adds the request line scripts to the normal 'MATCH' list.

Bug #1273.

11 years agotls: fix a tls.fingerprint issue in debug mode
Victor Julien [Fri, 19 Sep 2014 08:40:20 +0000 (10:40 +0200)] 
tls: fix a tls.fingerprint issue in debug mode

Print proper variable so we don't NULL-deref.

Bug #1279.

11 years agosource-nfq: fix display of next queue
Eric Leblond [Tue, 2 Sep 2014 13:33:34 +0000 (15:33 +0200)] 
source-nfq: fix display of next queue

Suricata was displaying an invalid queue number as the value is
shift at the moment of its assignement.

11 years agoBug fix: IPv6 addresses in negated range and IPv6 string into radix tree.
bmeeks8 [Fri, 5 Sep 2014 13:22:11 +0000 (09:22 -0400)] 
Bug fix: IPv6 addresses in negated range and IPv6 string into radix tree.

I found three somewhat serious IPv6 address bugs within the Suricata 2.0.x source code. Two are in the source module "detect-engine-address.c", and the third is in "util-radix-tree.c".

The first bug occurs within the function DetectAddressParse2(). When parsing an address string and a negated block is encountered (such as when parsing !$HOME_NET, for example), any corresponding IPv6 addresses were not getting added to the Group Heads in the DetectAddressList. Only IPv4 addresses were being added.

I discovered another bug related to IPv6 address ranges in the Signature Match Address Array comparison code for IPv6 addresses. The function DetectAddressMatchIPv6() walks a signature's source or destination match address list comparing each to the current packet's corresponding address value. The match address list consists of value pairs representing a lower and upper IP address range. If the packet's address is within that range (including equal to either the lower or upper bound), then a signature match flag is returned.

The original test of each signature match address to the packet was performed using a set of four compounded AND comparisons looking at each of the four 32-bit blocks that comprise an IPv6 address. The problem with the old comparison is that if ANY of the four 32-bit blocks failed the test, then a "no-match" was returned. This is incorrect. If one or more of the more significant 32-bit blocks met the condition, then it is a match no matter if some of the less significant 32-bit blocks did not meet the condition. Consider this example where Packet represents the packet address being checked, and Target represents the upper bound of a match address pair. We are testing if Packet is less than Target.

Packet -- 2001:0470 : 1f07:00e2 : 1988:01f1 : d468:27ab
Target -- 2001:0470 : 1f07:00e2 : a48c:2e52 : d121:101e

In this example the Packet's address is less than the target and it should give a match. However, the old code would compare each 32-bit block (shown spaced out above for clarity) and logically AND the result with the next least significant block comparison. If any of the four blocks failed the comparison, that kicked out the whole address. The flaw is illustrated above. The first two blocks are 2001:0470 and 1f07:00e2 and yield TRUE; the next less significant block is 1988:01f1 and a48c:2e52, and also yields TRUE (that is, Packet is less than Target); but the last block compare is FALSE (d468:27ab is not less than d121:101e). That last block is the least significant block, though, so its FALSE determination should not invalidate a TRUE from any of the more significant blocks. However, in the previous code using the compound logical AND block, that last least significant block would invalidate the tests done with the more significant blocks.

The other bug I found for IPv6 occurs when trying to parse and insert an IPv6 address into a Radix Tree using the function SCRadixAddKeyIPV6String(). The test for min and max values for an IPv6 CIDR mask incorrectly tests the upper limit as 32 when it should be 128 for an IPv6 address. I think this perhaps is an old copy-paste error if the IPv6 version of this function was initially copied from the corresponding IPv4 version directly above it in the code. Without this patch, the function will return null when you attempt to add an IPv6 network whose CIDR mask is larger than 32 (for example, the popular /64 mask will cause the function to return the NULL error condition).

(amended by Victor Julien)

11 years agoUpdate Changelog for 2.0.3 suricata-2.0.3
Victor Julien [Fri, 8 Aug 2014 07:49:18 +0000 (09:49 +0200)] 
Update Changelog for 2.0.3

11 years agostream: detect and filter out bad window updates 1093/head
Victor Julien [Wed, 16 Jul 2014 22:23:50 +0000 (00:23 +0200)] 
stream: detect and filter out bad window updates

Reported in bug 1238 is an issue where stream reassembly can be
disrupted.

A packet that was in-window, but otherwise unexpected set the
window to a really low value, causing the next *expected* packet
to be considered out of window. This lead to missing data in the
stream reassembly.

The packet was unexpected in various ways:
- it would ack unseen traffic
- it's sequence number would not match the expected next_seq
- set a really low window, while not being a proper window update

Detection however, it greatly hampered by the fact that in case of
packet loss, quite similar packets come in. Alerting in this case
is unwanted. Ignoring/skipping packets in this case as well.

The logic used in this patch is as follows. If:

- the packet is not a window update AND
- packet seq > next_seq AND
- packet acq > next_seq (packet acks unseen data) AND
- packet shrinks window more than it's own data size
THEN set event and skip the packet in the stream engine.

So in case of a segment with no data, any window shrinking is rejected.

Bug #1238.

11 years agoipv6: fix dst/hop header option parsing
Victor Julien [Thu, 7 Aug 2014 13:02:56 +0000 (15:02 +0200)] 
ipv6: fix dst/hop header option parsing

The extension header option parsing used a uint8_t internally. However
much bigger option sizes are valid.

11 years agodefrag: use 'struct timeval' for timeout tracking 1089/head
Victor Julien [Tue, 5 Aug 2014 15:28:17 +0000 (17:28 +0200)] 
defrag: use 'struct timeval' for timeout tracking

Until now the time out handling in defrag was done using a single
uint32_t that tracked seconds. This lead to corner cases, where
defrag trackers could be timed out a little too early.

11 years agoipv6: set event on unsupported nh
Victor Julien [Mon, 28 Jul 2014 12:41:15 +0000 (14:41 +0200)] 
ipv6: set event on unsupported nh

If a next header / protocol is encountered that we can't handle (yet)
set an event. Disabled the rule by default.

    decode-event:ipv6.unknown_next_header;

11 years agoipv6: more robust ipv6 exthdr handling
Victor Julien [Mon, 28 Jul 2014 11:59:44 +0000 (13:59 +0200)] 
ipv6: more robust ipv6 exthdr handling

Skip past Shim6, HIP and Mobility header.

Detect data after 'none' header.
    decode-event:ipv6.data_after_none_header;

11 years agoipv6: detect frag header reserved field non-zero
Victor Julien [Mon, 28 Jul 2014 10:07:13 +0000 (12:07 +0200)] 
ipv6: detect frag header reserved field non-zero

Frag Header length field is reserved, and should be set to 0.

    decode-event:ipv6.fh_non_zero_reserved_field;

11 years agoipv6: make exthdr parsing more robust
Victor Julien [Thu, 24 Jul 2014 14:50:34 +0000 (16:50 +0200)] 
ipv6: make exthdr parsing more robust

Improve data length checks. Detect PadN option with 0 length.

11 years agoipv6: set flag on type 0 routing header
Victor Julien [Thu, 17 Jul 2014 13:57:16 +0000 (15:57 +0200)] 
ipv6: set flag on type 0 routing header

Type 0 Routing headers are deprecated per RFC 5095.

This patch sets an decode event flag that can be matched on through:
    decode-event:ipv6.rh_type_0;

11 years agoipv6 defrag: fix unfragmentable exthdr handling
Victor Julien [Thu, 24 Jul 2014 11:39:10 +0000 (13:39 +0200)] 
ipv6 defrag: fix unfragmentable exthdr handling

Fix or rather implement handling of unfragmentable exthdrs in ipv6.
The exthdr(s) appearing before the frag header were copied into the
reassembled packet correctly, however the stripping of the frag header
did not work correctly.

Example:
The common case is a frag header directly after the ipv6 header:

[ipv6 header]->[frag header]->[icmpv6 (part1)]
[ipv6 header]->[frag header]->[icmpv6 (part2)]

This would result in:
[ipv6 header]->[icmpv6]

The ipv6 headers 'next header' setting would be updated to point to
whatever the frag header was pointing to.

This would also happen when is this case:

[ipv6 header]->[hop header]->[frag header]->[icmpv6 (part1)]
[ipv6 header]->[hop header]->[frag header]->[icmpv6 (part2)]

The result would be:
[ipv6 header]->[hop header]->[icmpv6]

However, here too the ipv6 header would have been updated to point
to what the frag header pointed at. So it would consider the hop header
as if it was an ICMPv6 header, or whatever the frag header pointed at.

The result is that packets would not be correctly parsed, and thus this
issue can lead to evasion.

This patch implements handling of the unfragmentable part. In the first
segment that is stored in the list for reassembly, this patch detects
unfragmentable headers and updates it to have the last unfragmentable
header point to the layer after the frag header.

Also, the ipv6 headers 'next hdr' is only updated if no unfragmentable
headers are used. If they are used, the original value is correct.

Reported-By: Rafael Schaefer <rschaefer@ernw.de>
Bug #1244.

11 years agoprscript: update URL
Eric Leblond [Thu, 31 Jul 2014 09:48:41 +0000 (11:48 +0200)] 
prscript: update URL

Buildbot server has been moved to another box.

11 years agomagic: disable tests depending on magic version
Victor Julien [Thu, 31 Jul 2014 13:49:11 +0000 (15:49 +0200)] 
magic: disable tests depending on magic version

Some tests depend on specific results by specific magic versions.
Disable these.

11 years agoUpdate app-layer-htp.c
sxhlinux [Thu, 24 Jul 2014 02:00:40 +0000 (10:00 +0800)] 
Update app-layer-htp.c

When keyword "boundary=" doesn't exist in the http_header, the value of r is 0 and this condition shouldn't return 0 instead 1;

11 years agotravis-ci: use make check
Eric Leblond [Fri, 4 Jul 2014 15:00:55 +0000 (17:00 +0200)] 
travis-ci: use make check

This patch replaces unittest run by make check. It also install
coccinelle so we should have more test.

11 years agococcinelle: fix problem with coccinelle 1.0rc21
Eric Leblond [Tue, 1 Jul 2014 17:27:34 +0000 (19:27 +0200)] 
coccinelle: fix problem with coccinelle 1.0rc21

coccinelle 1.0rc21 has a problem with regular expression handling.
This result in a Fatal Error when test system detects an coding
error.

This patch fixes the problem by using a simple blob inside
semantic patch instead of using a regular expression to define
the function.

It also fixes add an optimization on matching suppressing a
useless <.. ..> construction.

Fixes have been suggested by Julia Lawall.

11 years agoProfiling: fix compilation on CentOS5 1034/head
Victor Julien [Mon, 14 Jul 2014 13:25:50 +0000 (15:25 +0200)] 
Profiling: fix compilation on CentOS5

Bug #1207

11 years agohtp: init memuse atomics
Victor Julien [Mon, 14 Jul 2014 12:46:07 +0000 (14:46 +0200)] 
htp: init memuse atomics

In case of the spinlocked fallback code the lock was uninitialized.

11 years agoethtool: add missing include necessary for CentOS5
Victor Julien [Mon, 14 Jul 2014 12:42:54 +0000 (14:42 +0200)] 
ethtool: add missing include necessary for CentOS5

11 years agoFix compile-time error on old kernels and ethtool.h
Alexander Gozman [Fri, 13 Jun 2014 16:36:54 +0000 (20:36 +0400)] 
Fix compile-time error on old kernels and ethtool.h

11 years agoUpdate log-file.c 1024/head
sxhlinux [Thu, 10 Jul 2014 14:09:13 +0000 (22:09 +0800)] 
Update log-file.c

test whether tx_ud is NULL

11 years agoAdd initial travis-ci integration. 1016/head
Victor Julien [Fri, 4 Jul 2014 11:25:21 +0000 (13:25 +0200)] 
Add initial travis-ci integration.

11 years agoFix __thread configure check on Clang
Victor Julien [Wed, 2 Jul 2014 14:35:41 +0000 (16:35 +0200)] 
Fix __thread configure check on Clang

AC_TRY_COMPILE puts the code in a function already, and Clang didn't like
the function within the function declaration. This lead to test failure.

Clang now properly detects __thread support.

11 years agovalgrind/magic: add suppression for known issue
Victor Julien [Tue, 1 Jul 2014 09:11:08 +0000 (11:11 +0200)] 
valgrind/magic: add suppression for known issue

Add suppression for Ubuntu 14.04 64bit.

11 years agoFix lowercase table initialization (bug 1221)
Ken Steele [Tue, 24 Jun 2014 18:43:58 +0000 (14:43 -0400)] 
Fix lowercase table initialization (bug 1221)

The for loop needed to check for < 256, not < 255.

11 years agoUpdate Changelog for 2.0.2 release suricata-2.0.2
Victor Julien [Wed, 25 Jun 2014 13:29:18 +0000 (15:29 +0200)] 
Update Changelog for 2.0.2 release

11 years agolua: fix liblua use on OS X with macports
Victor Julien [Wed, 25 Jun 2014 08:44:30 +0000 (10:44 +0200)] 
lua: fix liblua use on OS X with macports

Set the correct lua pkg-config name used by macports.

11 years agodefrag: fix timeout setting when config is missing
Victor Julien [Mon, 16 Jun 2014 12:21:11 +0000 (14:21 +0200)] 
defrag: fix timeout setting when config is missing

When the config is missing, DefragPolicyGetHostTimeout will default
to returning -1. This will effectively set no timeout at all, leading
to defrag trackers being freed too early.

11 years agodefrag: fix reconstruction
Eric Leblond [Tue, 17 Jun 2014 09:19:05 +0000 (11:19 +0200)] 
defrag: fix reconstruction

This patch is fixing an issue in defragmentation code. The
insertion of a fragment in the list of fragments is done with
respect to the offset of the fragment. But the code was using
the original offset of the fragment and not the one of the
new reconstructed fragment (which can be different in the
case of overlapping segment where the left part is trimmed).

This case could lead to some evasion techniques by causing
Suricata to analyse a different payload.

11 years agounix socket: fix valgrind issue
Eric Leblond [Fri, 20 Jun 2014 16:11:29 +0000 (18:11 +0200)] 
unix socket: fix valgrind issue

This patch fixes the following issue reported by valgrind:
 31 errors in context 1 of 1:
 Conditional jump or move depends on uninitialised value(s)
    at 0x8AB2F8: UnixSocketPcapFilesCheck (runmode-unix-socket.c:279)
    by 0x97725D: UnixCommandBackgroundTasks (unix-manager.c:368)
    by 0x97BC52: UnixManagerThread (unix-manager.c:884)
    by 0x6155F6D: start_thread (pthread_create.c:311)
    by 0x6E3A9CC: clone (clone.S:113)

The running field in PcapCommand was not initialized.

11 years agounix-manager: fix crash when client disconnect
Eric Leblond [Fri, 20 Jun 2014 15:46:47 +0000 (17:46 +0200)] 
unix-manager: fix crash when client disconnect

This patch fixes an issue in unix socket handling. It is possible
that a socket did disconnect when analysing a command and because
the data treatment is done in a loop on clients this was leading
to a update of the list of clients during the loop. So we need
in fact to use TAILQ_FOREACH_SAFE instead of TAILQ_FOREACH.

Reported-by: Luigi Sandon <luigi.sandon@gmail.com>
Fix-suggested-by: Luigi Sandon <luigi.sandon@gmail.com>
11 years agoRework Tile CPU affinity setting to handle non-contiguous sets of CPUs.
Ken Steele [Fri, 20 Jun 2014 18:53:16 +0000 (14:53 -0400)] 
Rework Tile CPU affinity setting to handle non-contiguous sets of CPUs.

It is possible to have a non-contiguous CPU set, which was not being
handled correctly on the TILE architecture.

Added a "rank" field in the ThreadVar to store the worker's rank separately
from the cpu for this case.

11 years agoFix bug #1206 999/head
Mats Klepsland [Mon, 23 Jun 2014 07:14:16 +0000 (09:14 +0200)] 
Fix bug #1206

PF_RING ZC uses clusters in the same way as PF_RING DNA. Therefore,
this bug can be fixed as it was fixed for DNA (bug #598).

11 years agohtp: make htp state handling function more robust
Victor Julien [Thu, 19 Jun 2014 08:36:36 +0000 (10:36 +0200)] 
htp: make htp state handling function more robust

Also, fix wrong cast that worked only by luck.

11 years agohttp: remove BUG_ON(1) statement
Victor Julien [Tue, 17 Jun 2014 11:56:47 +0000 (13:56 +0200)] 
http: remove BUG_ON(1) statement

Remove BUG_ON(1) statement that was a leftover from debugging.

Bug #1189
Bug #1212

11 years agoFix issue #1214 995/head
Alessandro Guido [Fri, 20 Jun 2014 12:01:11 +0000 (14:01 +0200)] 
Fix issue #1214

When applying wildcard thresholds (with sid = 0 and/or gid = 0) it's wrong
to exit on the first signature already having an event filter. Indeed,
doing so results in the theshold not being applied to all subsequent
signatures. Change the code in order to skip signatures with event
filters instead of breaking out of the loop.

11 years agoFix libcap-ng configure typo.
Victor Julien [Thu, 12 Jun 2014 09:54:31 +0000 (11:54 +0200)] 
Fix libcap-ng configure typo.

11 years agoBug 1098: improve invalid pcre/R handling 987/head
Victor Julien [Tue, 10 Jun 2014 15:31:28 +0000 (17:31 +0200)] 
Bug 1098: improve invalid pcre/R handling

When not using a file_data or similar 'sticky buffer', a pcre/R option
needs a content in the same buffer.

11 years agonflog: fix memory leaks
Giuseppe Longo [Fri, 6 Jun 2014 09:48:15 +0000 (11:48 +0200)] 
nflog: fix memory leaks

This fixes the following memory leaks:

[src/source-nflog.c:222]: (error) Memory leak: ntv
[src/source-nflog.c:236]: (error) Memory leak: ntv
[src/source-nflog.c:253]: (error) Memory leak: ntv
[src/source-nflog.c:258]: (error) Memory leak: ntv

11 years agocygwin: fix lua configure
Victor Julien [Wed, 4 Jun 2014 16:01:52 +0000 (18:01 +0200)] 
cygwin: fix lua configure

Fix lua configure for cygwin. Tested with lua 5.1.5.

11 years agoFix live reload segv when startup isn't complete 982/head
Victor Julien [Tue, 20 May 2014 11:03:09 +0000 (13:03 +0200)] 
Fix live reload segv when startup isn't complete

If a live reload signal was given before the engine was fully started
up (e.g. pcap file thread waiting for a disk to spin up), a segv could
occur.

This patch only enables live reloads after the threads have been
started up completely.

11 years agoFix Coverity 1220098 and 1220099 981/head
Victor Julien [Wed, 4 Jun 2014 15:11:29 +0000 (17:11 +0200)] 
Fix Coverity 1220098 and 1220099

*** CID 1220098:  Missing unlock  (LOCK)
/src/log-droplog.c: 195 in LogDropLogNetFilter()
189         SCMutexLock(&dlt->file_ctx->fp_mutex);
190
191         if (dlt->file_ctx->rotation_flag) {
192             dlt->file_ctx->rotation_flag  = 0;
193             if (SCConfLogReopen(dlt->file_ctx) != 0) {
194                 /* Rotation failed, error already logged. */
>>>     CID 1220098:  Missing unlock  (LOCK)
>>>     Returning without unlocking "dlt->file_ctx->fp_mutex".
195                 return TM_ECODE_FAILED;
196             }
197         }
198
199         if (dlt->file_ctx == NULL) {
200             return TM_ECODE_FAILED;

*** CID 1220099:  Dereference before null check  (REVERSE_INULL)
/src/log-droplog.c: 199 in LogDropLogNetFilter()
193             if (SCConfLogReopen(dlt->file_ctx) != 0) {
194                 /* Rotation failed, error already logged. */
195                 return TM_ECODE_FAILED;
196             }
197         }
198
>>>     CID 1220099:  Dereference before null check  (REVERSE_INULL)
>>>     Null-checking "dlt->file_ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
199         if (dlt->file_ctx == NULL) {
200             return TM_ECODE_FAILED;
201         }
202
203         char srcip[46] = "";
204         char dstip[46] = "";

11 years agoFix Coverity 1220097
Victor Julien [Wed, 4 Jun 2014 14:54:56 +0000 (16:54 +0200)] 
Fix Coverity 1220097

*** CID 1220097:  Missing unlock  (LOCK)
/src/log-file.c: 160 in LogFileWriteJsonRecord()
154             }
155         }
156
157         /* Bail early if no file pointer to write to (in the unlikely
158          * event file rotation failed. */
159         if (aft->file_ctx->fp == NULL) {
>>>     CID 1220097:  Missing unlock  (LOCK)
>>>     Returning without unlocking "aft->file_ctx->fp_mutex".
160             return;
161         }
162
163         FILE *fp = aft->file_ctx->fp;
164         char timebuf[64];
165         AppProto alproto = FlowGetAppProtocol(p->flow);

11 years agoUnregister for file rotation notification when a context is
Jason Ish [Tue, 27 May 2014 16:07:50 +0000 (10:07 -0600)] 
Unregister for file rotation notification when a context is
de-initialized.  Required for unix-socket mode where
contexts come and go.

11 years agoAdd signal based file rotation for:
Jason Ish [Tue, 4 Mar 2014 16:43:36 +0000 (10:43 -0600)] 
Add signal based file rotation for:
- alert debug log
- fast log
- stats log
- dns log
- drop log
- file log
- http log
- tls log
- eve/json log

11 years agoAdd macros for access to the underlying buffer and offset.
Jason Ish [Tue, 4 Mar 2014 16:42:19 +0000 (10:42 -0600)] 
Add macros for access to the underlying buffer and offset.
Useful for using passing the buffer through to another writer
such as LogFileCtx.

11 years agoAdd a rotation flag to LogFileCtx which loggers can use to register
Jason Ish [Tue, 4 Mar 2014 16:40:10 +0000 (10:40 -0600)] 
Add a rotation flag to LogFileCtx which loggers can use to register
for log rotation.  Have the LogFileCtx handle the log rotation.

11 years agoRegistration for SIGHUP notification - for loggers interested
Jason Ish [Tue, 4 Mar 2014 16:34:33 +0000 (10:34 -0600)] 
Registration for SIGHUP notification - for loggers interested
in file rotation on SIGHUP.

11 years agolua/luajit: use HAVE_LUA mostly 980/head
Victor Julien [Thu, 13 Mar 2014 15:24:51 +0000 (16:24 +0100)] 
lua/luajit: use HAVE_LUA mostly

Only use HAVE_LUAJIT if things are done differently from HAVE_LUA,
like in the states pool.

11 years agolua: deal with FreeBSD and OpenBSD
Victor Julien [Thu, 20 Mar 2014 09:33:57 +0000 (10:33 +0100)] 
lua: deal with FreeBSD and OpenBSD

FreeBSD pkg-config lua-5.1.pc, lib liblua-5.1.so
OpenBSD pkg-config lua51.pc, lib liblua5.1.so

Default (linux) pkg-config: lua5.1.pc, lib liblua5.1.so

11 years agolua: support regular lua C library
Victor Julien [Thu, 13 Mar 2014 14:10:10 +0000 (15:10 +0100)] 
lua: support regular lua C library

Not all systems have luajit or a need for luajit. For low bandwidth
and offline support regular lua may be sufficient.

11 years agoprofiling: use wider columns in keyword output
Victor Julien [Mon, 2 Jun 2014 14:46:02 +0000 (16:46 +0200)] 
profiling: use wider columns in keyword output

Use wider columns in keyword output so that even on high end sensors
the stats tables remain readable.

11 years agofix regression in 'make distclean' due to commit cd305c3a
Noam Meltzer [Thu, 8 May 2014 06:26:43 +0000 (09:26 +0300)] 
fix regression in 'make distclean' due to commit cd305c3a

the files under scripts/suricatasc/src are actual sources and should not
be cleaned

11 years agobugfix in debug mode:
jeka [Tue, 20 May 2014 09:20:59 +0000 (12:20 +0300)] 
bugfix in debug mode:

removed function calls from SCReturnX macros

11 years agonflog: set socket timeout 978/head
Victor Julien [Mon, 26 May 2014 10:45:59 +0000 (12:45 +0200)] 
nflog: set socket timeout

Set socket timeout so that we can exit if there is no traffic.

It would hang after the SIGINT signal, until packets arived.

11 years agonflog: warn if buffer-size is larger than max-size
Victor Julien [Mon, 26 May 2014 10:40:50 +0000 (12:40 +0200)] 
nflog: warn if buffer-size is larger than max-size

If buffer-size is larger than max size, give a warning and adjust
buffer-size to max-size.

11 years agodns: unify type to string logging utility
Victor Julien [Sat, 24 May 2014 16:48:18 +0000 (18:48 +0200)] 
dns: unify type to string logging utility

Both DNS loggers had their own CreateTypeString. This patch unifies
them.

11 years agodns: add names for common types
Victor Julien [Sat, 24 May 2014 16:37:14 +0000 (18:37 +0200)] 
dns: add names for common types

Add names for SRV, NAPTR, DS, RRSIG, NSEC, NSEC3 types.

11 years agonflog: fix typo rising->raising
Victor Julien [Fri, 23 May 2014 10:42:48 +0000 (12:42 +0200)] 
nflog: fix typo rising->raising

11 years agonflog: improve error handling on NOBUFS
Victor Julien [Wed, 21 May 2014 08:15:28 +0000 (10:15 +0200)] 
nflog: improve error handling on NOBUFS

Don't fall through to handle_packet on any NOBUFS condition. Make
sure we catch all NOBUFS.

11 years agoThis patch adds the fields into PacketVars struct to setup a packet from a nflog...
Giuseppe Longo [Wed, 26 Feb 2014 13:57:31 +0000 (14:57 +0100)] 
This patch adds the fields into PacketVars struct to setup a packet from a nflog message

11 years agoAdds nflog option
Giuseppe Longo [Sat, 1 Feb 2014 10:34:33 +0000 (11:34 +0100)] 
Adds nflog option

11 years agoDeclare a wrapper to parse group option for nflog
Giuseppe Longo [Sat, 1 Feb 2014 10:32:12 +0000 (11:32 +0100)] 
Declare a wrapper to parse group option for nflog

11 years agoImplements NFLOG runmode
Giuseppe Longo [Wed, 1 Jan 2014 21:04:54 +0000 (22:04 +0100)] 
Implements NFLOG runmode

11 years agoBootstraping NFLOG capture mode
Giuseppe Longo [Sun, 15 Dec 2013 14:29:12 +0000 (15:29 +0100)] 
Bootstraping NFLOG capture mode

11 years agoAdds nflog error code
Giuseppe Longo [Sat, 14 Dec 2013 12:29:24 +0000 (13:29 +0100)] 
Adds nflog error code

11 years agoUpdating the Tmm Id for declaration of nflog capture mode
Giuseppe Longo [Sat, 14 Dec 2013 12:28:27 +0000 (13:28 +0100)] 
Updating the Tmm Id for declaration of nflog capture mode

11 years agoAdds a configuration example for nflog support in suricata.yaml
Giuseppe Longo [Sat, 14 Dec 2013 09:40:57 +0000 (10:40 +0100)] 
Adds a configuration example for nflog support in suricata.yaml

11 years agoChecks if libnetfilter_log is found on the system
Giuseppe Longo [Tue, 10 Dec 2013 12:19:25 +0000 (13:19 +0100)] 
Checks if libnetfilter_log is found on the system
and enable it if it's specified.

11 years agotls: check SSL3/TLS version per record 973/head
Victor Julien [Fri, 2 May 2014 12:20:13 +0000 (14:20 +0200)] 
tls: check SSL3/TLS version per record

Set event if SSL3/TLS record isn't within the acceptable range.

11 years agodns: add tests for TXT response parsing 972/head
Victor Julien [Thu, 15 May 2014 12:01:54 +0000 (14:01 +0200)] 
dns: add tests for TXT response parsing

Add valid and invalid examples.

11 years agodns json: log TXT response data
Victor Julien [Thu, 15 May 2014 09:14:54 +0000 (11:14 +0200)] 
dns json: log TXT response data

Log TXT data in the rdata field.

11 years agodns: parse and store TXT responses
Victor Julien [Thu, 15 May 2014 09:14:30 +0000 (11:14 +0200)] 
dns: parse and store TXT responses

This way the TXT data can be logged by the loggers.

Ticket #1158

11 years agoUpdate Changelog for 2.0.1 suricata-2.0.1
Victor Julien [Wed, 21 May 2014 08:26:59 +0000 (10:26 +0200)] 
Update Changelog for 2.0.1

11 years agoUpdate Changelog for 2.0.1rc1 changes suricata-2.0.1rc1
Victor Julien [Mon, 12 May 2014 11:43:58 +0000 (13:43 +0200)] 
Update Changelog for 2.0.1rc1 changes

11 years agojson output: don't set 'unknown' for missing data 965/head
Victor Julien [Tue, 6 May 2014 11:54:03 +0000 (13:54 +0200)] 
json output: don't set 'unknown' for missing data

Instead of setting 'unknown' or '<unknown>' just pass NULL to json_*
function, which results in omitting the data.

11 years agoeve-log: swap ip/port pairs in dns answers
Tom DeCanio [Wed, 23 Apr 2014 15:41:15 +0000 (08:41 -0700)] 
eve-log: swap ip/port pairs in dns answers

11 years agohttp-json: fix coverity warning
Victor Julien [Fri, 2 May 2014 15:11:10 +0000 (17:11 +0200)] 
http-json: fix coverity warning

*** CID 1211009:  Bad bit shift operation  (BAD_SHIFT)
/src/output-json-http.c: 265 in JsonHttpLogJSON()
259         /* log custom fields if configured */
260         if (http_ctx->fields != 0)
261         {
262             HttpField f;
263             for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
264             {
>>>     CID 1211009:  Bad bit shift operation  (BAD_SHIFT)
>>>     In expression "1 << f", left shifting by more than 31 bits has undefined behavior.  The shift amount, "f", is as much as 46.
265                 if ((http_ctx->fields & (1<<f)) != 0)
266                 {
267                     /* prevent logging a field twice if extended logging is
268                        enabled */
269                     if (((http_ctx->flags & LOG_HTTP_EXTENDED) == 0) ||
270                         ((http_ctx->flags & LOG_HTTP_EXTENDED) !=

________________________________________________________________________________________________________
*** CID 1211010:  Bad bit shift operation  (BAD_SHIFT)
/src/output-json-http.c: 492 in OutputHttpLogInitSub()
486                         {
487                             if ((strcmp(http_fields[f].config_field,
488                                        field->val) == 0) ||
489                                 (strcasecmp(http_fields[f].htp_field,
490                                             field->val) == 0))
491                             {
>>>     CID 1211010:  Bad bit shift operation  (BAD_SHIFT)
>>>     In expression "1 << f", left shifting by more than 31 bits has undefined behavior.  The shift amount, "f", is as much as 46.
492                                 http_ctx->fields |= (1<<f);
493                                 break;
494                             }
495                         }
496                     }
497                 }

11 years agounix-socket: reset logging api's properly 963/head
Victor Julien [Fri, 2 May 2014 14:32:49 +0000 (16:32 +0200)] 
unix-socket: reset logging api's properly

Lack of proper reset lead to logs not being written after the first
pcap had been processed.

11 years agostream: cleanup 961/head
Victor Julien [Thu, 24 Apr 2014 15:31:08 +0000 (17:31 +0200)] 
stream: cleanup

StreamTcpSetDisableRawReassemblyFlag() has the same effect as
AppLayerParserTriggerRawStreamReassembly in that it will force the
raw reassembly to flush out asap. So it is redundant to call both.

11 years agostream: implement raw reassembly stop api
Victor Julien [Thu, 24 Apr 2014 08:48:37 +0000 (10:48 +0200)] 
stream: implement raw reassembly stop api

Implement StreamTcpSetDisableRawReassemblyFlag() which stops raw
reassembly for _NEW_ segments in a stream direction.

It is used only by TLS/SSL now, to flag the streams as encrypted.
Existing segments will still be reassembled and inspected, while
new segments won't be. This allows for pattern based inspection
of the TLS handshake.

Like is the case with completely disabled 'raw' reassembly, the
logic is that the segments are flagged as completed for 'raw' right
away. So they are not considered in raw reassembly anymore.

As no new segments will be considered, the chunk limit check will
return true on the next call.

11 years agostream: unify segment discard handling
Victor Julien [Thu, 24 Apr 2014 08:02:21 +0000 (10:02 +0200)] 
stream: unify segment discard handling

Have a single function StreamTcpReturnSegmentCheck determine if a
segment is ready to be removed from the stream.

Handle FLOW_NOPAYLOAD_INSPECT in raw reassembly.

11 years agoapp-layer: improve no payload inspect flag
Victor Julien [Wed, 23 Apr 2014 15:55:24 +0000 (17:55 +0200)] 
app-layer: improve no payload inspect flag

If setting APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD, trigger raw
reassembly.