Commit Graph

4565 Commits (1cce207c0502c4122282db366c54ed95bbd342b2)
 

Author SHA1 Message Date
Victor Julien 1cce207c05 Revert TmqhFlowMode alignment as it breaks on CLANG 11 years ago
Victor Julien 9874c1a83b realloc error handling: remove unnecessary else branch 11 years ago
Eric Leblond 1fbaebad63 coccinelle: add test on realloc
If we use SCRealloc like:
 x = SCRealloc(x, ...)
then in case of failure we are loosing the original pointer value
and the memory is lost and can not be free.

This test just check for this construction and output an error if
it finds it.
11 years ago
Eric Leblond 1f07d1521e Fix realloc error handling
This patch is fixing realloc error handling. In case of a realloc
failure, it free the initial memory and continue existing error
handling.

The patch has been obtained via the following semantic patch and
a bit oh hand editing:

@@
expression x, E;
identifier f;
@@

f(...)
{
+ void *ptmp;
<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (x == NULL)
+ if (ptmp == NULL)
{
+ SCFree(x);
+ x = NULL;
...
- }
+ } else {
+     x = ptmp;
+ }
...+>
}

@@
expression x, E;
identifier f;
statement ES;
@@

f(...) {
+ void *ptmp;

<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (x == NULL) ES
+ if (ptmp == NULL) {
+ SCFree(x);
+ x = NULL;
+ ES
+ } else {
+     x = ptmp;
+ }
...+>

}

@@
expression x, E;
identifier f;
@@

f(...)
{
+ void *ptmp;
<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (unlikely(x == NULL))
+ if (unlikely(ptmp == NULL))
{
+ SCFree(x);
+ x = NULL;
...
- }
+ } else {
+     x = ptmp;
+ }
...+>
}

@@
expression x, E;
identifier f;
statement ES;
@@

f(...) {
+ void *ptmp;

<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (unlikely(x == NULL)) ES
+ if (unlikely(ptmp == NULL)) {
+ SCFree(x);
+ x = NULL;
+ ES
+ } else {
+     x = ptmp;
+ }
...+>

}
11 years ago
Victor Julien 5e1f1ee4ff Fix filemagic unittests on OS_DARWIN 11 years ago
Ken Steele d12834769a Add const for Packet * in flow functions.
By moving FlowReference() out of FlowGetFlowFromHash() and into the one
function that calls it, all the flow functions take const Packet * instead
of Packet *.
11 years ago
Giuseppe Longo 8ba0fa7f92 defrag-config: fix a bug
A ptr to local var is stored in the radix tree currently,
this patch permits to alloc space to store host timeout
and thus also free it when data is removed.
11 years ago
Victor Julien de22d6cf02 defrag: fix compiler warning
defrag-config.c: In function 'DefragParseParameters':
defrag-config.c:105: warning: passing argument 2 of 'DefragPolicyAddHostInfo' from incompatible pointer type
make[3]: *** [defrag-config.o] Error 1
11 years ago
Victor Julien 2913a4a860 debug: fix realloc error checking on flowbit print
detect.c:1074:17: warning: Potential leak of memory pointed to by \
                                field 'debuglog_flowbits_names'
                return;

Bug #1062.
11 years ago
Victor Julien b605ee6fb2 DER decoding: fix potential memory leak
This would only happen in memory failure conditions.

util-decode-der.c:634:27: warning: Potential leak of memory pointed to by 'child'
    return (Asn1Generic *)node;
11 years ago
Victor Julien 2f094ca136 detect-ssl: suppress harmless scan-build warning
detect-ssl-version.c:271:17: warning: Value stored to 'neg' is never read
                neg = 0;
11 years ago
Victor Julien 1252ee3f04 stream: suppress minor scan-build warnings
stream-tcp-reassemble.c:2569:17: warning: Value stored to 'seg' is never read
                seg = seg->next;
                ^     ~~~~~~~~~
stream-tcp-reassemble.c:2587:17: warning: Value stored to 'seg' is never read
                seg = seg->next;
11 years ago
Victor Julien 9d092f35e2 dns: suppress minor scan-build warnings
These were only used if debug is enabled.

app-layer-dns-tcp.c:407:13: warning: Value stored to 'length' is never read
            length = *data;
app-layer-dns-udp.c:236:13: warning: Value stored to 'length' is never read
            length = *data;
11 years ago
Victor Julien 6ac30ae468 dns: suppress harmless cppcheck warning
[src/app-layer-dns-common.c:273]: (warning) Assignment of function \
                        parameter has no effect outside the function.
11 years ago
Victor Julien 66c6c06916 http: clear header pointer on realloc failure
Fixes:

detect-engine-hhd.c:188:5: warning: Use of memory after it is freed
    return headers_buffer;
11 years ago
Victor Julien 7ea13f0f53 dns: fix passing NULL to memcpy
app-layer-dns-common.c:401:5: warning: Null pointer passed as \
                              an argument to a 'nonnull' parameter
    memcpy(ptr, fqdn, fqdn_len);
11 years ago
Victor Julien 6709fdd8cf log-http: fix compiler warning
log-httplog.c:180: warning: 'cvalue' may be used uninitialized in \
this function
11 years ago
Victor Julien 31a94cd4cb defrag: pass u64 to ParseU64
Fixes: defrag-config.c:97: warning: passing argument 2 \
       of 'ParseSizeStringU64' from incompatible pointer type
11 years ago
Ken Steele 12ab6f3ab4 Fix uninitialized variable warning.
These two lines reported warnings with -Werror -O3 on Tile.
11 years ago
Ken Steele 882d98733f Fix pfring so that zero-copy mode can work.
Detect when default_packet_size is zero, which enables zero-copy mode for
pfring and in that case, do what AF Packet does and set pkt_ext pointer to
the data and set PKT_ZERO_COPY flag.
11 years ago
Ken Steele f9705377ae Remove pkt variable from Packet structure.
The uint8_t *pkt in the Packet structure always points to the memory
immediately following the Packet structure. It is better to simply
calculate that value every time than store the 8 byte pointer.
11 years ago
Ken Steele 3870def601 Split AC-Tile MPM context into Search and Initialization structures.
Some of the fields in the SCACTileCtx struct are only used to create the MPM,
but are not needed to search the MPM. Create a new structure to contain just
the data needed by AC Search. After creating the MPM, copy the data into the
new structure and then free the memory only needed during initialization.

This reduces the size of the AC-Tile MPM context from 1360 bytes down to 296
bytes.
11 years ago
Victor Julien b61552482c mpipe code cleanup: indent fixes 11 years ago
Ken Steele 300b739b1f Add more suricata.yaml configuration options for mPIPE.
Add two new mPIPE load-balancing configuration options in suricata.yaml.
1) "sticky" which keep sending flows to one CPU, but if that queue is full,
don't drop the packet, move the flow to the least loaded queue.
2) Round-robin, which always picks the least full input queue for each
packet.

Allow configuring the number of packets in the input queue (iqueue) in
suricata.yaml.

For the mPipe.buckets configuration, which must be a power of 2, round
up to the next power of two, rather than report an error.

Added mpipe.min-buckets, which defaults to 256, so if the requested number
of buckets can't be allocated, Suricata will keep dividing by 2 until either
it succeeds in allocating buckets, or reaches the minimum number of buckets
and fails.
11 years ago
Ken Steele f0c785cc1d Fix configuring Prelude with -Werror
Running with:

CFLAGS="-Werror" ./configure

would fail when configuring libprelude because of an unused-result
warning. Ignore that one warning.
11 years ago
Ken Steele 5a1bc025e5 Mark pflow as a constant pointer.
Address review comment from Victor that the pflow pointer is constant, so
it can be marked as such.
11 years ago
Ken Steele bee24d8909 Use pflow variable in place of p->flow to prevent reloading.
In SigMatchSignatures, the value p->flow doens't change, but GCC can't
figure that out, so it reloads p->flow many times during the function.
When p->flow is loaded into the variable pflow once at the start of the
function, the compile then doesn't need to reload it.
11 years ago
Eric Leblond a75911e02f pfring: workaround potential librt deps
It seems some version of pfring needs to be link with librt.
11 years ago
Eric Leblond 58eb6428d1 suricata: ignore SIGHUP signal
This patch ignores the SIGHUP signal instead of having the default
behavior.
11 years ago
Ken Steele 3d81e50ab3 Check for compiler for -march=native support
Check all compilers to see if they support the -march=native flags, rather
than assuming gcc 4.2 or later does. Tile GCC doesn't currently support it,
so not checking break Tile compiles.
11 years ago
Victor Julien 4fdd1a7a71 Fix compilation on systems that use the fallback SC_ATOMIC_ API. 11 years ago
Victor Julien 01c440bf28 Add DrMemory suppression for Bug #980. Suppress useless (likely) buggy leak message too 11 years ago
Victor Julien 1509c9a2e6 Remove DrMemory suppressions for Bug #979, it is fixed. 11 years ago
Eric Leblond 5a7ad5b382 qa: prscript now output pastable line for PR. 11 years ago
Eric Leblond a597237aed coccinelle: fix malloc test
We can have more than an identifier to be assigned the result of
a malloc function.
11 years ago
Eric Leblond 6378db89f6 coccinelle: add option to continue on errors
When a script has been updated or introduced, it is interesting to
detect all errors at once. With this patch it is now possible to
do so by using:
   NOT_TERMINAL=1 CONCURRENCY_LEVEL=12  qa/coccinelle/run_check.sh
11 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.
11 years ago
Victor Julien f6e37dcc90 Bug 1061: fix multiple vars per sig in ordering
In sigordering rules that had multiple vars doing the same operation,
like setting multiple flowbits, would not be considered correctly.

Bug 1061.
11 years ago
Victor Julien b770fd2981 http header: improve realloc failure checking. Bug #1062. 11 years ago
Victor Julien 90cf8d4c6e port parsing: improve memory handling 11 years ago
Victor Julien b79b2fff25 cppcheck: add special BUG_ON so cppcheck understands we exit 11 years ago
Victor Julien d5db0cc033 port: don't lead memory on port parsing failure
[src/detect-engine-port.c:1354]: (error) Memory leak: gh
11 years ago
Victor Julien 435f99409f Fix small memleak in runmode setup
[src/runmodes.c:338]: (error) Memory leak: custom_mode
11 years ago
Victor Julien 86aad660a2 threading setup: fix small mem leak on failure
[src/tm-threads.c:1058]: (error) Memory leak: slot
11 years ago
Victor Julien b4631794a8 Fix realloc error handling in threshold.config file parsing. Bug #1062. 11 years ago
Victor Julien 35298a0146 Use %u for unsigned int in (console) output 11 years ago
Victor Julien a9d754c23d Use %u for unsigned ints in checksum warning 11 years ago
Victor Julien 76d3cb557b htp: minor cleanup to silence cppcheck warning
[src/app-layer-htp.c:1967] -> [src/app-layer-htp.c:1978]: (warning) \
    Possible null pointer dereference: tx - otherwise it is redundant \
    to check it against null.
11 years ago
Victor Julien 5ba898b738 cppcheck: don't use likely/unlikely when -DCPPCHECK is passed to the checker 11 years ago
Victor Julien b2c4a50e39 Fix small memory leak in classtype parsing 11 years ago