Commit Graph

6470 Commits (e75a93b1256e604d2528baff76b9c236057dba64)
 

Author SHA1 Message Date
Eric Leblond 9dec6d933f output-json-email: fix memleak in error path
In JsonEmailLogJsonData function, an invalid state was leading to
early exit without a proper freeing of resources.

This should fix:

Indirect leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x4c264b in malloc (/home/victor/qa/buildbot/donkey/z600fuzz/Private/src/.libs/lt-suricata+0x4c264b)
    #1 0x7fb09c1e886a in json_object (/usr/lib/x86_64-linux-gnu/libjansson.so.4+0x686a)
    #2 0xd6a272 in JsonEmailLogJson /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-json-email-common.c:370:19
    #3 0xd956b9 in JsonSmtpLogger /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-json-smtp.c:103:9
    #4 0xdcedac in OutputTxLog /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-tx.c:165:17
    #5 0xff6669 in TmThreadsSlotVarRun /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/tm-threads.c:132:17
    #6 0xffecc1 in TmThreadsSlotVar /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/tm-threads.c:474:17
    #7 0x7fb09bfcc181 in start_thread /build/eglibc-3GlaMS/eglibc-2.19/nptl/pthread_create.c:312
9 years ago
Eric Leblond 92ad63abb7 output-json-email: fix error code
Returning early if first function call fail could avoid some issue.
9 years ago
JonZeolla b5972eeea2 Fix typos in an error message
Fix two minor typos in a SC_ERR_INVALID_ARGUMENT error message.
9 years ago
gureedo e4443fac53 netmap: fix issue 1717
Use packet pool only without packet allocation.
Wait for N packets available in packet pool before netmap ring fetching.
9 years ago
gureedo 02d4e729c4 netmap: fix log typo 9 years ago
gureedo f891aadefc netmap: remove workers zero copy mode restriction between interfaces
Rationale: https://github.com/luigirizzo/netmap/issues/126
9 years ago
Mats Klepsland eb39487f48 app-layer-ssl: fix out of bounds memory read
Added several checks to avoid out of bounds memory read caused
by malformed traffic.
10 years ago
Victor Julien ef4c717052 ip parsing: fix cppcheck negative shift warning
[src/util-ip.c:104]: (error) Shifting a negative value is undefined behaviour
[src/util-radix-tree.c:1160]: (error) Shifting a negative value is undefined behaviour
[src/util-radix-tree.c:1357]: (error) Shifting a negative value is undefined behaviour
[src/util-radix-tree.c:1380]: (error) Shifting a negative value is undefined behaviour
[src/util-radix-tree.c:1438]: (error) Shifting a negative value is undefined behaviour
10 years ago
Victor Julien a70ff19911 stats: fix unix socket crash
Reset counters_global_id at ctx destruction. In the unix socket
runmode the lack of this reset would cause the id's to increase with
each pcap, leading to an ever larger stats array.
10 years ago
Jason Ish 3c3fe4b47d detect: denote the max detection list; fix issue 1674.
Denotes the max detection list so that rule validation can
allow post-detection lists to come after base64_data, but
disallow detection lists to come after it.
10 years ago
Victor Julien 9afaf14ba4 smtp: use detection file tracking
As SMTP file_data detection uses the file API, the file's inspect
tracker should be considered when pruning files.

This patch sets the FILE_USE_DETECT flag on files tracked by smtp.

It also adds logic to move inspected tracker ahead if detection
doesn't do it, like when no rules are matching or detection engine
is disabled.
10 years ago
Victor Julien 77358a4113 file: optionally use detect tracking in pruning
When the file API is used to do content inspection (currently only
smtp does this), the detection should be considered while pruning
the file chunks.

This patch introduces a new flag for the file API: FILE_USE_DETECT

When it is used, 'FilePrune' will not remove chunks that are (partly)
beyond the File::content_inspected tracker.

When using this flag, it's important to realize that when the detect
engine is disabled or rules are not matching, content_inspected
might not get updated.
10 years ago
Victor Julien 5aee386fa9 smtp: add file_data debug code 10 years ago
Victor Julien c19412243a file logging: fix bad end of file check
File storage could end file storing when the logger was invoked
while no new data chunks were available.
10 years ago
Victor Julien 4526aed2b1 smtp: fix config parsing and config defaults 10 years ago
Victor Julien 32bf68aef8 smtp: consider file state in file_data inspection limits 10 years ago
Victor Julien 4783d5107f pfring: strip prio from vlan id 10 years ago
Victor Julien 01a8cc4ec9 afpacket: strip prio from vlan id 10 years ago
Victor Julien 8394b38941 cppcheck: work around snprintf warning
Cppcheck 1.72 gives a warning on the following code pattern:

    char blah[32] = "";
    snprintf(blah, sizeof(blah), "something");

The warning is:

    (error) Buffer is accessed out of bounds.

While this appears to be a FP, in most cases the initialization to ""
was unnecessary as the snprintf statement immediately follows the
variable declaration.
10 years ago
Mats Klepsland 33fd710367 rules: add rules for TLS SNI app layer events 10 years ago
Mats Klepsland 7602f650b1 app-layer-ssl: fix memleak
Avoid that the SNI extension code is executed twice sometimes, causing
memory leaks.
10 years ago
Victor Julien f17ef5e46b daemon: suppress coverity resource leak warning (CID 400725) 10 years ago
Victor Julien ed93e9394d coverity: suppress CID 1038112 10 years ago
Victor Julien 444c4b546e htp: optimize multipart parsing
Store boundary in a single stack buffer instead of 2 heap allocated
buffers.
10 years ago
Victor Julien 665cafbe3b htp: fix boundry error handling (CID 1153934) 10 years ago
Victor Julien bfc4be230c htp: fix dead code warning (CID 1153933) 10 years ago
Victor Julien b4912f3bf9 unified2: fix unused value warning (CID 1247404) 10 years ago
Victor Julien a46c4da338 lua: fix unlikely null-deref during setup (CID 1351209) 10 years ago
Victor Julien c858bfea4a base64_decode: fix potential keyword parsing issue (CID 1340064) 10 years ago
Victor Julien 2a7f068438 ioctl: fix NULL check after dereference (CID 1204326) 10 years ago
Victor Julien dff9f65ce7 lua: fix minor coverity issues
Remove checks that can never be false. CID 1232076, 1312012
10 years ago
Victor Julien 339f066533 afpacket: suppress harmless Coverity warning (1192960) 10 years ago
Victor Julien e91b9bf22b Fix compilation on systems with Musl 10 years ago
Victor Julien c91546022d smtp: clean up thread local memory 10 years ago
Victor Julien 12d7c86efc stream-tcp: improve function doc 10 years ago
Victor Julien 81878c1998 Add global MAX macro. 10 years ago
Maurizio Abba 44a7c12ad0 decode-events: counters for decode events errors
We want to add counters in order to track the number of times we hit a
decode event. A decode event is related to an error in the protocol
decoding over a certain packet.

This patch fist modifies the decode-event list, reordering it in order
to separate single packet events from stream-related events and adding
the prefix "decoder" to decode events.
The counters are created during the decode setup and the relative event
counter is increased every time a packet with the flag PKT_IS_INVALID is
finalized in the decode phase
10 years ago
Eric Leblond b7bf299e3b af-packet: don't check GRO LRO on non ethernet
This way we avoid an error message when sniffing on a non Ethernet
device.
10 years ago
Eric Leblond 11eb1d7c1d af-packet: handle raw link
If no link layer header is reported then it is a raw header.
10 years ago
Eric Leblond 994bc15c2a af-packet: disable most code when not built in
When af-packet is not build we can avoid to build a large amount
of code.
10 years ago
Victor Julien e4059fb541 stream: fix stream.inline default
If stream.inline setting was missing it would default to IDS.

This patch changes the default to 'auto', meaning that in IPS mode
the stream engine also uses IPS mode and in IDS mode it's still in
IDS mode.

Bug #1570
10 years ago
Victor Julien bda9869af7 dns: turn debug BUG_ON's into events 10 years ago
Victor Julien c0b16fa2bb detect: allow for more than 64k mpm rules 10 years ago
Victor Julien 8f4eff5f50 defrag: fix bad packet error handling
When defrag creates a new reassembled IP packet, it then passes this
packet to the IP decoder. If this decoder returns an error the packet
is returned back to the packet pool with a call to TmqhOutputPacketpool

This lead to the first problem. The returned packet had it's p->root
pointer set, and it's PKT_TUNNEL flag set. This could cause problems
in TmqhOutputPacketpool, as this may reference the packet referenced
in p->root.

The second and more glaring problem is that the packet that was
returned to the packetpool, was still returned by the Defrag function
and processed further. It would then at the end of it's processing
be returned to the packet pool, which at this point already had a
reference to this packet.

This patch fixes both issues by unsetting the tunnel references and
returning NULL from Defrag in this case.
10 years ago
Victor Julien 4e90b54666 packet pool: make sure packet next ptr is always set 10 years ago
Victor Julien 3ac1468c1b packet pool: turn bad check into BUG_ON 10 years ago
Andreas Herz c8399e8c51 configure: bypass libpcre 8.35 check
When --with-libpcre-libraries is used we skip the libpcre 8.35 check
since pkg-config might still point to the 8.35 version installed
although newer version was passed with --with-libpcre-libraries.
10 years ago
Eric Leblond f001c10ac4 util-radix-tree: fix memleak
Logic used when adding a new prefix to a node was not correct
as we were allocating a prefix that could be at the end unused.
This patch is updating the code to have a complete creation to
be done if and only if we are needing the complete object. In
the other cases, it was enough to use the function input values.

This fixes:

104 (48 direct, 56 indirect) bytes in 2 blocks are definitely lost in loss record 184 of 327
   at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x9C2DAD: SCRadixCreatePrefix (util-radix-tree.c:144)
   by 0x9AFA5B: SCRadixAddKey (util-radix-tree.c:522)
   by 0x9B1A4D: SCRadixAddKeyIPV4Netblock (util-radix-tree.c:897)
   by 0x67C824: IPOnlyPrepare (detect-engine-iponly.c:1197)
   by 0x55172B: SigAddressPrepareStage2 (detect.c:3534)
   by 0x5486F4: SigGroupBuild (detect.c:4671)
   by 0x547C87: SigLoadSignatures (detect.c:538)
   by 0x8FB5D0: LoadSignatures (suricata.c:1976)
   by 0x8F3B32: main (suricata.c:2342)
10 years ago
Eric Leblond 9c7e18dc89 detect-ssl-state: fix memleak 10 years ago
Eric Leblond fe81bdc213 detect-ssl-version: simplify code and fix memlea 10 years ago