Commit Graph

94 Commits (f37eb88bbf9b1d278fd9570eca3179d63375a906)

Author SHA1 Message Date
Eric Leblond f37eb88bbf
Merge 460a7f9615 into 9a37bb659b 2 days ago
Philippe Antoine 8461e3f3e7 src: do not include "util-unittest.h" directly
It is included in suricata-common.h

Ticket: 945
3 weeks ago
Eric Leblond 460a7f9615 conf: better handling of set
In the case of --set=foo.0=bar, the 0 was not creating a sequence
if ever the sequence is not existing.

Ticket: 8606
3 weeks ago
Eric Leblond 1db9575bd2 conf: add an util to iterate on sequence
A YAML sequence of single key maps, such as `outputs`, stores its
entries at outputs.<n>.<name> so a direct lookup of outputs.<name>
never matches. Add SCConfNodeLookupInSequence() to walk such a
sequence and return the entries matching a given name.

Ticket: 8606
3 weeks ago
Victor Julien 32414573a7 conf: assist gcc -fanalyzer
Work around TAILQ false positive.
5 months ago
Philippe Antoine a9e1dff4a6 conf: introduce SCConfGetNonNull
Ticket: 8651

Behaves like SCConfGet but returns 0 on null value
5 months ago
Jeff Lucovsky 022a79fdd5 misc/cleanup: Simplify <cond> ? true : false
Simplify statements where there's a conditional statement followed by
return true or return false.

Instead of
    if (conditional)
        return true;
    else
        return false;

Use:
        return conditional
7 months ago
Lukas Sismis 85f0382072 conf: add time parsing conf function 10 months ago
Jason Ish d89b35db56 conf: add SCConfNodeChildValueIsFalse to check for false value
New function to check is a value is actually set to a false value.
10 months ago
Philippe Antoine 30af626a92 conf: extend API for rust
Will allow rust to list the values of an array such as
dns.types for outputs
2 years ago
Jason Ish 22b77b0c56 conf: prefix conf API with SC 2 years ago
Philippe Antoine 20423fdd38 style: remove some useless return
and remove empty line before end of function
2 years ago
Philippe Antoine b113bdd9e3 src: remove unused headers-exported functions
+ remove double definition of IPPairLock

Ticket: #4083
3 years ago
Shivani Bhardwaj 72ee505aa0 conf: check if node value is Null
Bug: #6303, #6302
3 years ago
Victor Julien 1186036a88 conf: spelling 4 years ago
Jason Ish 3d92990c6f conf: document ConfGetChildValueBool 4 years ago
Jason Ish fbb0d2b0f4 config: allow fully qualified overrides
Allow configuration parameters to be overrided usually a fully
qualified name such as:

vars.address-groups.HOME_NET: "7.1.2.0/24"

In configuration files (including "include" files).  This allows the
overriding of a specific value deeply nested in the configuration
without having to redefine the complete top-layer object.

Ticket: 4783
4 years ago
Victor Julien b31ffde6f4 output: remove error codes from output 4 years ago
Victor Julien e042cd785e error: use SC_ENOMEM for alloc errors 4 years ago
Victor Julien 39cf5b151a src: includes cleanup
Work towards making `suricata-common.h` only introduce system headers
and other things that are independent of complex internal Suricata
data structures.

Update files to compile after this.

Remove special DPDK handling for strlcpy and strlcat, as this caused
many compilation failures w/o including DPDK headers for all files.

Remove packet macros from decode.h and move them into their own file,
turn them into functions and rename them to match our function naming
policy.
4 years ago
Jason Ish adda8801d8 conf: remove ConfGetValue
All uses of ConfGetValue are satisfied by ConfGet
4 years ago
Lukas Sismis a7faed1245 dpdk: initial support with workers runmode
Register a new runmode - DPDK. This enables a new flag on Suricata start
(--dpdk).

With the flag given, DPDK runmode is enabled.

Runmode loads the configuration and then initializes EAL.

If successful, it configures the physical NICs according to the configuration
file. After that, worker threads are initialized and then are in continuous
receive loop.
5 years ago
Shivani Bhardwaj 6f7d8e50c8 src: use FatalError whenever possible
Replaces all patterns of SCLogError() followed by exit() with
FatalError(). Cocci script to do this:

@@
constant C;
constant char[] msg;
@@

- SCLogError(C,
+ FatalError(SC_ERR_FATAL,
  msg);
- exit(EXIT_FAILURE);

Closes redmine ticket 3188.
6 years ago
Victor Julien 49b02f8f1b mingw: minor compile warning fixes 9 years ago
Jason Ish 472cc8ea61 conf: new function: ConfNodeHasChildren
Test if a configuration node has any children, indicating
that it is a non-empty map or sequence.
9 years ago
Eric Leblond ba0899a77f conf: add function to get child with default 9 years ago
Wolfgang Hotwagner a463910ff2 Conf: Multipe NULL-pointer dereferences after ConfGetBool in StreamTcpInitConfig
There are multiple NULL-pointer dereferences after calling ConfGetBool in StreamTcpInitConfig. ConfGetBool calls ConfGet which doesn't check the vptr-argument. This is a sample ASAN-output:

1453ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f2969b83a28 bp 0x7ffdbf613a90 sp 0x7ffdbf613210 T0)
 0 0x7f2969b83a27 in strcasecmp (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27)
 1 0x564185accefd in ConfValIsTrue /root/suricata-1/src/conf.c:559
 2 0x564185accb4f in ConfGetBool /root/suricata-1/src/conf.c:512
 3 0x564185dcbe05 in StreamTcpInitConfig /root/suricata-1/src/stream-tcp.c:381
 4 0x564185e21a88 in PreRunInit /root/suricata-1/src/suricata.c:2264
 5 0x564185e24d2c in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2763
 6 0x564185e2570e in main /root/suricata-1/src/suricata.c:2898
 7 0x7f29662cb2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
 8 0x5641859b6039 in _start (/usr/local/bin/suricata+0xc8039)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27) in strcasecmp
1453ABORTING

This commit replaces ConfGet by ConfGetValue in ConfGetBool. This does not only fix Bug #2368 but might also fix others too.
9 years ago
Wolfgang Hotwagner 08971f1841 conf: multiple NULL-pointer dereferences in StreamTcpInitConfig
There are several NULL-pointer derefs in StreamTCPInitConfig. All of them happen because ConfGet returns 1 even if the value is NULL(due to misconfiguration for example).
This commit introduces a new function "ConfGetValue". It adds return values for NULL-pointer to ConfGet and could be used as a replacement for ConfGet.

Note: Simply modify ConfGet might not be a good idea, because there are some places where ConfGet should return 1 even if "value" is NULL. For example if ConfGet should get a Config-Leave in the yaml-hierarchy.

Bug: 2354
9 years ago
Wolfgang Hotwagner 094632730e conf: fix NULL-pointer dereference in ConfGetInt
If there are empty values in the config-file where integer values are expected, strtoimax in the ConfGetInt-function will segfault because of NULL-pointer dereference.

Here is a configuration example:

pcre.match-limit: []

This will let suricata crash with a segfault.
ASAN-output:

ASAN:DEADLYSIGNAL =================================================================
16951ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa690e3ccc5 bp 0x000000000000 sp 0x7ffd0d770ad0 T0)
0 0x7fa690e3ccc4 (/lib/x86_64-linux-gnu/libc.so.6+0x36cc4)
1 0x7fa6946a6534 in strtoimax (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x44534)
2 0x55e0aeba6499 in ConfGetInt /root/suricata-1/src/conf.c:390
3 0x55e0aed2545d in DetectPcreRegister /root/suricata-1/src/detect-pcre.c:99
4 0x55e0aec1b4ce in SigTableSetup /root/suricata-1/src/detect.c:3783
5 0x55e0aeeed58d in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2690
6 0x55e0aeeee4f2 in main /root/suricata-1/src/suricata.c:2892
7 0x7fa690e262b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
8 0x55e0aea92d39 in _start (/usr/local/bin/suricata+0xc7d39)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x36cc4)

This commit fixes Ticket #2275
9 years ago
Victor Julien 72dd663e00 yaml: print errors if integers are invalid 9 years ago
Victor Julien ab1200fbd7 compiler: more strict compiler warnings
Set flags by default:

    -Wmissing-prototypes
    -Wmissing-declarations
    -Wstrict-prototypes
    -Wwrite-strings
    -Wcast-align
    -Wbad-function-cast
    -Wformat-security
    -Wno-format-nonliteral
    -Wmissing-format-attribute
    -funsigned-char

Fix minor compiler warnings for these new flags on gcc and clang.
10 years ago
Victor Julien 613174e9ce yaml: fix tests for -Wshadow 10 years ago
Jason Ish dcdf160ab2 conf: cleanup compiler warning (unintialized vars) 10 years ago
Jason Ish d7d05b007c conf: use new testing macros
Also don't bother with cleanup on failure.
11 years ago
Jason Ish 796dd5223b tests: no longer necessary to provide successful return code
1 pass, 0 is fail.
11 years ago
Jason Ish 4352dd179c conf: null guard in ConfNodeLookupChild
Add NULL guarding to the lookup so callers can process nodes
in a loop with less error checking.

Addresses issue #1660.
11 years ago
Jason Ish ae23144b67 --set - handle spaces on either side of '='
Discard spaces when provided as part of --set around the '='. For
example, "val=key", "val = key", "val= key" and "val =key" are
all equivalent now.
12 years ago
Jason Ish d9fe95bc8a conf - function declaration style
Use consistent style - function return type and declaration on
same line.
12 years ago
Jason Ish 6ed246c041 Don't attempt to load the rule files if the rule-files configuration
node is not a sequence.  Instead log a warning as this is usually
a configuration error.
12 years ago
Jason Ish a243a42bdf New function to test if a configuration node is a sequence or not. 12 years ago
Victor Julien 844065bf58 conf api: use const pointers where possible
Use const pointers where possible in the Conf API.
12 years ago
Victor Julien b955ca7b86 conf: fix potential use-after-free on error
Coverity 1139544

If strdup would fail, 'node' was freed but it wasn't set to NULL. The
code then returned node. The caller would not detect there was an error
and use the freed pointer.
13 years ago
Ken Steele 12ab6f3ab4 Fix uninitialized variable warning.
These two lines reported warnings with -Werror -O3 on Tile.
13 years ago
Eric Leblond 28c5c68192 error checking: add missing alloc error treatment
The return of some malloc like functions was not treated in some
places of the code.
13 years ago
Jason Ish eaff01a57f Use the stack for temporary memory buffers. 13 years ago
Jason Ish ab7091927e When setting final configuration nodes, set the whole tree as final.
Prevents benign log message of parent nodes of final values being
redefined (which ends up having no affect as the final nodes
are protected from being removed).
13 years ago
Jason Ish 8d29dfca59 Instead of exiting on memory failure, log a warning then return NULL
to signify an error to the caller.
13 years ago
Jason Ish 5f6705c4dc Better document ConfSet and ConfSetFinal. 13 years ago
Jason Ish c981a16579 Function to prune all non-final nodes from a configuration node. 13 years ago
Jason Ish b8e13d4bd6 More concise API for setting config values that
can be overrided or not (final values).
13 years ago