]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agoapp-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap() 3183/head
Martin Natano [Mon, 30 Oct 2017 15:03:25 +0000 (16:03 +0100)] 
app-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap()

RAND_MAX is not guaranteed to be a divisor of ULONG_MAX, so take the
necessary precautions to get unbiased random numbers. Although the
bias might be negligible, it's not advisable to rely on it.

7 years agodetect: minor cleanup
Victor Julien [Tue, 23 Jan 2018 07:55:37 +0000 (08:55 +0100)] 
detect: minor cleanup

7 years agosignal: use centralized pthread_sigmask for signals
Maurizio Abba [Tue, 16 Jan 2018 18:12:28 +0000 (18:12 +0000)] 
signal: use centralized pthread_sigmask for signals

according to its man page, sigprocmask has undefined behavior in
multithreaded environments. Instead of explictly blocking the handling
of SIGUSR2 in every thread, direct block handling SIGUSR2 before
creating the threads and enable again the handling of this signal
afterwards. In this way, only the main thread will be able to manage
this signal properly.

7 years agothreshold: minor cleanups
Victor Julien [Tue, 23 Jan 2018 07:44:46 +0000 (08:44 +0100)] 
threshold: minor cleanups

7 years agorate_filter: by_rule fixed triggering algorithm
Ruslan Usmanov [Tue, 12 Dec 2017 18:10:07 +0000 (13:10 -0500)] 
rate_filter: by_rule fixed triggering algorithm

Fixes issue #2258

Program was triggering rate_filter by_rule earlier than needed
and generally behaved like a threshold.

7 years agodetect/content: implement endswith 3182/head
Victor Julien [Tue, 19 Dec 2017 15:14:33 +0000 (16:14 +0100)] 
detect/content: implement endswith

7 years agodetect/content: introduce startswith modifier
Victor Julien [Sat, 16 Dec 2017 10:44:18 +0000 (11:44 +0100)] 
detect/content: introduce startswith modifier

Add startswith modifier to simplify matching patterns at the start
of a buffer.

Instead of:
    content:"abc"; depth:3;
This enables:
    content:"abc"; startswith;

Especially with longer patterns this makes the intention of the rule
more clear and eases writing the rules.

Internally it's simply a shorthand for 'depth:<pattern len>;'.

Ticket https://redmine.openinfosecfoundation.org/issues/742

7 years agodetect: bypass merge sort call if possible
Victor Julien [Thu, 2 Nov 2017 11:44:29 +0000 (12:44 +0100)] 
detect: bypass merge sort call if possible

7 years agodetect: profiling update for new detect code
Victor Julien [Wed, 1 Nov 2017 16:38:22 +0000 (17:38 +0100)] 
detect: profiling update for new detect code

7 years agodetect/prefilter: redo profiling
Victor Julien [Tue, 31 Oct 2017 16:48:18 +0000 (17:48 +0100)] 
detect/prefilter: redo profiling

7 years agodetect/profiling: postpone setup
Victor Julien [Mon, 23 Oct 2017 08:48:56 +0000 (10:48 +0200)] 
detect/profiling: postpone setup

Do this to allow for including of runtime buffer registrations.

7 years agodetect/fast-pattern: use registered buffers for check
Victor Julien [Mon, 23 Oct 2017 10:29:55 +0000 (12:29 +0200)] 
detect/fast-pattern: use registered buffers for check

7 years agooutput/filedata: call loggers on both directions
Victor Julien [Fri, 12 Jan 2018 07:49:20 +0000 (08:49 +0100)] 
output/filedata: call loggers on both directions

7 years agooutput/file: run file loggers in both directions
Victor Julien [Thu, 11 Jan 2018 19:42:54 +0000 (20:42 +0100)] 
output/file: run file loggers in both directions

This avoids the wait for injected packets when file is already ready
to be logged.

7 years agodetect/state: clean up old code
Victor Julien [Thu, 11 Jan 2018 12:50:59 +0000 (13:50 +0100)] 
detect/state: clean up old code

7 years agodetect: fix multiple files per tx inspect
Victor Julien [Wed, 10 Jan 2018 18:17:33 +0000 (19:17 +0100)] 
detect: fix multiple files per tx inspect

Fix the inspection of multiple files in a single TX, where new files
may be added to the TX after inspection started.

Assign the hard coded id DE_STATE_FLAG_FILE_INSPECT to the file
inspect engine.

Make sure that sigs that do file inspection and don't match on the
current file always store a detailed state. This state will include
the DE_STATE_FLAG_FILE_INSPECT flag.

When the app-layer indicates a new file is available, for each sig
that has the DE_STATE_FLAG_FILE_INSPECT flag set, reset part of the
state so that the sig is evaluated again.

7 years agoapp-layer: improve async and out of order txs
Victor Julien [Wed, 11 Oct 2017 17:02:43 +0000 (19:02 +0200)] 
app-layer: improve async and out of order txs

Free txs that are done out of order if we can. Some protocol
implementations have transactions running in parallel, where it is
possible that a tx that started later finishes earlier than other
transactions. Support freeing those.

Also improve handling on asynchronious transactions. If transactions
are unreplied, e.g. in the dns flood case, the parser may at some
point free transactions on it's own. Handle this case in
the app-layer engine so that the various tracking id's (inspect, log,
and 'min') are updated accordingly.

Next, free txs much more aggressively. Instead of freeing old txs
at the app-layer parsing stage, free all complete txs at the end
of the flow-worker. This frees txs much sooner in many cases.

7 years agodetect/prefilter: show prefilter engine id space
Victor Julien [Tue, 10 Oct 2017 10:40:03 +0000 (12:40 +0200)] 
detect/prefilter: show prefilter engine id space

7 years agoapp-layer: warn that MpmIDs API is no longer used
Victor Julien [Tue, 10 Oct 2017 09:54:35 +0000 (11:54 +0200)] 
app-layer: warn that MpmIDs API is no longer used

Remove implementation.

7 years agodetect/flowbits: apply state knowledge
Victor Julien [Tue, 9 Jan 2018 16:52:19 +0000 (17:52 +0100)] 
detect/flowbits: apply state knowledge

When stateless rules are depending on a flowbit being set by a stateful
rule, the inspection order is almost certainly wrong.

Switch stateless rules depending on stateful rules to being stateful.
This is used to turn 'TCP stream' inspecting rules (which are stateless
unless mixed with stateful keywords) into stateful rules.

7 years agodetect: rewrite of the detect engine
Victor Julien [Sun, 8 Oct 2017 09:42:30 +0000 (11:42 +0200)] 
detect: rewrite of the detect engine

Use per tx detect_flags to track prefilter. Detect flags are used for 2
things:
1. marking tx as fully inspected
2. tracking already run prefilter (incl mpm) engines

This supercedes the MpmIDs API for directionless tracking
of the prefilter engines.

When we have no SGH we have to flag the txs that are 'complete'
as inspected as well.

Special handling for the stream engine:

If a rule mixes TX inspection and STREAM inspection, we can encounter
the case where the rule is evaluated against multiple transactions
during a single inspection run. As the stream data is exactly the same
for each of those runs, it's wasteful to rerun inspection of the stream
portion of the rule.

This patch enables caching of the stream 'inspect engine' result in
the local 'RuleMatchCandidateTx' array. This is valid only during the
live of a single inspection run.

Remove stateful inspection from 'mask' (SignatureMask). The mask wasn't
used in most cases for those rules anyway, as there we rely on the
prefilter. Add a alproto check to catch the remaining cases.

When building the active non-mpm/non-prefilter list check not just
the mask, but also the alproto. This especially helps stateful rules
with negated mpm.

Simplify AppLayerParserHasDecoderEvents usage in detection to only
return true if protocol detection events are set. Other detection is done
in inspect engines.

Move rule group lookup and handling into it's own function. Handle
'post lookup' tasks immediately, instead of after the first detect
run. The tasks were independent of the initial detection.

Many cleanups and much refactoring.

7 years agorust/nfs: add support for detect_flags API
Victor Julien [Mon, 16 Oct 2017 13:30:28 +0000 (15:30 +0200)] 
rust/nfs: add support for detect_flags API

7 years agodns: support detect flags
Victor Julien [Wed, 17 Jan 2018 14:13:55 +0000 (15:13 +0100)] 
dns: support detect flags

7 years agorust/dns: implement detect_flags API
Victor Julien [Fri, 13 Oct 2017 06:12:21 +0000 (08:12 +0200)] 
rust/dns: implement detect_flags API

7 years agohttp: move from MpmIDs to DetectFlags API
Victor Julien [Tue, 10 Oct 2017 09:54:02 +0000 (11:54 +0200)] 
http: move from MpmIDs to DetectFlags API

7 years agossl/tls: use DetectFlags API
Victor Julien [Tue, 17 Oct 2017 08:19:41 +0000 (10:19 +0200)] 
ssl/tls: use DetectFlags API

7 years agosmtp: implement DetectFlags API
Victor Julien [Mon, 16 Oct 2017 13:56:53 +0000 (15:56 +0200)] 
smtp: implement DetectFlags API

7 years agossh: implement DetectFlags API
Victor Julien [Mon, 16 Oct 2017 13:48:05 +0000 (15:48 +0200)] 
ssh: implement DetectFlags API

7 years agoapp-layer: detect flags API calls
Victor Julien [Tue, 10 Oct 2017 09:17:52 +0000 (11:17 +0200)] 
app-layer: detect flags API calls

Add API meant to replace the MpmIDs API. It uses a u64 for each direction
in a tx to keep track of 2 things:

1. is inspection done?
2. which prefilter engines (like mpm) are already completed

7 years agoflowbits: analyze and dump to json
Victor Julien [Fri, 13 Oct 2017 09:01:38 +0000 (11:01 +0200)] 
flowbits: analyze and dump to json

Analyze flowbits to find which bits are only checked.

Track whether they are set and checked on the same level of 'statefulness'
for later used.

Dump flowbits to json including the sids that set/check etc the bit.

7 years agofilestore: minor cleanups and warning fixes
Victor Julien [Thu, 18 Jan 2018 16:38:09 +0000 (17:38 +0100)] 
filestore: minor cleanups and warning fixes

7 years agosuricatasc: don't use find -delete 3175/head
Jason Ish [Thu, 18 Jan 2018 12:42:19 +0000 (06:42 -0600)] 
suricatasc: don't use find -delete

For when -delete isn't supported by find. Instead use
-print0 with xargs -0.

7 years agodoc: document file-store v2
Jason Ish [Wed, 17 Jan 2018 13:51:38 +0000 (07:51 -0600)] 
doc: document file-store v2

7 years agofilestore: only allow one filestore to be enabled
Jason Ish [Fri, 12 Jan 2018 20:46:31 +0000 (14:46 -0600)] 
filestore: only allow one filestore to be enabled

There is probably not too much bad about enabling both, but
open file counts can get messy with both enabled. And v1
should be schedule for deprecation soon enough.

7 years agofilestore (old): register global stat in init func
Jason Ish [Fri, 12 Jan 2018 20:43:01 +0000 (14:43 -0600)] 
filestore (old): register global stat in init func

This doesn't need to be registered from suricata.c. And moving
it to the init function makes sure its only registered if
the logger is actually enabled.

7 years agofilestore2: warn once for file errors
Jason Ish [Fri, 12 Jan 2018 19:35:51 +0000 (13:35 -0600)] 
filestore2: warn once for file errors

Track each type of error warning and only log it once. Also create
a new stat, file_store.fs_errors to count each file system type
error (open, rename, unlink).

Also remove exit stats, they are of limited value.

7 years agoutil-error: define SC_ERR_MAX
Jason Ish [Fri, 12 Jan 2018 18:56:42 +0000 (12:56 -0600)] 
util-error: define SC_ERR_MAX

7 years agosuricatactl: a new python script for misc. tasks
Jason Ish [Tue, 9 Jan 2018 13:51:26 +0000 (07:51 -0600)] 
suricatactl: a new python script for misc. tasks

Use a new directory, Python to host the Suricata python modules.
One entry point is suricatactl, a control script for
miscalleneous tasks. Currently onl filestore pruning
is implemented.

7 years agofilestore v2: use fileinfo records as metadata
Jason Ish [Mon, 8 Jan 2018 20:09:01 +0000 (14:09 -0600)] 
filestore v2: use fileinfo records as metadata

As fileinfo records are logged to the main eve log, disable
metadata by default. But when enabled, just use the fileinfo
record.

Metadata is stored in a file named:
  <sha256>.<seconds>.<file_id>.json

where the sha256 is the same as the file logged, the seconds
is the unix timestamp in seconds for the fileinfo record,
and the file_id is an atomically incremented integer per
Suricata instance.

This should allow for each occurrence of the same file to have
its own metadata file. But a collision is expected when running
Suricata repeatedly over the same pcap, as that would be the
exact same occurrence of a file.

7 years agofile extract: force sha256 even if truncated
Jason Ish [Mon, 8 Jan 2018 19:39:56 +0000 (13:39 -0600)] 
file extract: force sha256 even if truncated

Even if a file is truncated, force the SHA256 if force sha256
is set to yes.

The new file store requires the sha256 regardless of the file
state if it is to be logged, as the filename is based on the
sha256.

7 years agofilestore v2 - initial version
Jason Ish [Thu, 4 Jan 2018 20:28:29 +0000 (14:28 -0600)] 
filestore v2 - initial version

Filestore v2 is starts as a copy of log-filestore with the
following changes.

- NSS is required as file names as based on the SHA256.
- Work/tmp files are stored in a temp. directory, then
  moved into a directory tree where the directory names
  are the first 2 characters of the hex SHA256.
- Removes the need for a waldo file or pid in the filenames.

7 years agoconfigure: check for utime.h and utime()
Jason Ish [Mon, 8 Jan 2018 21:11:54 +0000 (15:11 -0600)] 
configure: check for utime.h and utime()

7 years agooutput-json-file: let caller decide if file is stored
Jason Ish [Thu, 18 Jan 2018 12:17:00 +0000 (06:17 -0600)] 
output-json-file: let caller decide if file is stored

Mainly for the filestore module, which may have its own
knowledge of the file being stored before others.

7 years agoeve/fileinfo: split record creation from writing
Jason Ish [Mon, 8 Jan 2018 19:41:34 +0000 (13:41 -0600)] 
eve/fileinfo: split record creation from writing

Split the building of the fileinfo record from the writing
of the record so the building can be called from other code.
Specifically the new filestore output which uses fileinfo
records as the metadata.

7 years agoutil-error: new error: SC_ERR_CREATE_DIRECTORY
Jason Ish [Thu, 4 Jan 2018 17:14:42 +0000 (11:14 -0600)] 
util-error: new error: SC_ERR_CREATE_DIRECTORY

For logging directory create errors.

7 years agoSCPathExists - function to see if a path exists
Jason Ish [Thu, 4 Jan 2018 17:11:06 +0000 (11:11 -0600)] 
SCPathExists - function to see if a path exists

Returns true if path exists, otherwise false.

7 years agocreate directory: final arg to control full path or prefix
Jason Ish [Thu, 4 Jan 2018 17:07:50 +0000 (11:07 -0600)] 
create directory: final arg to control full path or prefix

Give SCCreateDirectoryTree a new argument, final. If true the
full path will be created as a directory. If false, the last
component will not be created as a directory (current
behaviour).

7 years agocreate directory: fix strlcpy usage
Jason Ish [Thu, 4 Jan 2018 17:04:52 +0000 (11:04 -0600)] 
create directory: fix strlcpy usage

The final character was being cut off.

7 years agoutil: move SCCreateDirectoryTree to util-path
Jason Ish [Thu, 4 Jan 2018 16:06:31 +0000 (10:06 -0600)] 
util: move SCCreateDirectoryTree to util-path

Renames SCLogCreateDirectoryTree to SCCreateDirectoryTree
and move into a util module for re-use.

Also moves SCMkDir from suricata-common.h to the more
appropriately names util-path.h.

I would have prefered to use util-file for file related options
but that is already used by file store utilities. util-path
is close enough for file related operations.

7 years agooutput: introduce init return type
Jason Ish [Thu, 11 Jan 2018 22:34:33 +0000 (16:34 -0600)] 
output: introduce init return type

The new OutputInitResult is a struct return type that allows
logger init functions to return a NULL context without
raising error.

Instead of returning NULL to signal error, the "ok" field will
be set to false. If ok, but the ctx is NULL, then silently
move on to the next logger.

Use case: multiple versions of a specific logger, and one
implementation decides the configuration is not for that
implemenation. It can return NULL, ok.

7 years agothresholds: fix issues with host based thresholds 3168/head
Victor Julien [Tue, 16 Jan 2018 10:54:39 +0000 (11:54 +0100)] 
thresholds: fix issues with host based thresholds

The flow manager thread (that also runs the host cleanup code) would
sometimes free a host before it's thresholds are timed out. This would
lead to misdetection or too many alerts.

This was mostly (only?) visible on slower systems. And was caused by a
mismatch between time concepts of the async flow manager thread and the
packet threads, resulting in the flow manager using a timestamp that
was before the threshold entry creation ts. This would lead to an
integer underflow in the timeout check, leading to a incorrect conclusion
that the threshold entry was timed out.

To address this,  check if the 'check' timestamp is not before the creation
timestamp.

7 years agostream/midstream: be more liberal with window
Victor Julien [Wed, 17 Jan 2018 12:04:54 +0000 (13:04 +0100)] 
stream/midstream: be more liberal with window

Use the wscale setting when updating the window, even if it's very
high.

7 years agothreads: don't crash in slow shutdown 3157/head
Victor Julien [Mon, 15 Jan 2018 17:16:47 +0000 (18:16 +0100)] 
threads: don't crash in slow shutdown

If TmThreadDrainPacketThreads would take more than 60 seconds, the wait
loop that follows it would reach 'timeout' condition immediately. This
would lead to a null ptr deref of 'tv'.

Fix by not counting the TmThreadDrainPacketThreads and also not doing
the null ptr deref in any case.

7 years agotime: Force init cached_minute_start array
Maurizio Abba [Thu, 11 Jan 2018 14:34:37 +0000 (14:34 +0000)] 
time: Force init cached_minute_start array

In offline mode, if the starting timestamp is 0 suricata will never
initialize cached_minute_start array. This cause the timestamp to be
ignored when needed (e.g., in fast.log).

This commit will force the initialization of this array.

7 years agoNTP: ensure parser name is not freed after registration
Pierre Chifflier [Sat, 13 Jan 2018 15:09:26 +0000 (16:09 +0100)] 
NTP: ensure parser name is not freed after registration

7 years agoutil-time: Add function to convert timespec to epoch millis
Danny Browning [Sat, 13 Jan 2018 14:45:25 +0000 (07:45 -0700)] 
util-time: Add function to convert timespec to epoch millis

7 years agodestate: test cleanups
Victor Julien [Wed, 10 Jan 2018 15:24:08 +0000 (16:24 +0100)] 
destate: test cleanups

7 years agohttp: clean up & improve unittests
Victor Julien [Wed, 10 Jan 2018 11:59:52 +0000 (12:59 +0100)] 
http: clean up & improve unittests

7 years agoconf: add function to get child with default
Eric Leblond [Sat, 6 Jan 2018 09:01:55 +0000 (10:01 +0100)] 
conf: add function to get child with default

7 years agoaf-packet: synchronize flags sizes
Eric Leblond [Fri, 5 Jan 2018 21:32:34 +0000 (22:32 +0100)] 
af-packet: synchronize flags sizes

They are passed from config to threads so they need to be of the
same size.

7 years agoprint: Escape backslash in PrintRawUriFp
Maurizio Abba [Thu, 11 Jan 2018 15:21:06 +0000 (15:21 +0000)] 
print: Escape backslash in PrintRawUriFp

PrintRawUriFp does not properly escape backslash. This causes confusion
between a \ character and an hex-encoded character. PrintRawUriBuffer,
instead, correctly does backslash-encoding.
Adding proper escaping of backslash to PrintRawUriFp.

7 years agoRust: remove deprecated functions LoggerFlags::get_logged/set_logged 3140/head
Pierre Chifflier [Thu, 11 Jan 2018 17:54:28 +0000 (18:54 +0100)] 
Rust: remove deprecated functions LoggerFlags::get_logged/set_logged

7 years agoNTP: update logger to use new API
Pierre Chifflier [Thu, 11 Jan 2018 07:17:23 +0000 (08:17 +0100)] 
NTP: update logger to use new API

7 years agooutput: add missing dnp3 profiling labels 3135/head
Victor Julien [Mon, 8 Jan 2018 19:37:28 +0000 (20:37 +0100)] 
output: add missing dnp3 profiling labels

7 years agologging: unique id's per log direction
Victor Julien [Mon, 8 Jan 2018 18:46:06 +0000 (19:46 +0100)] 
logging: unique id's per log direction

For loggers that register once per direction, use unique id's per
direction.

Reshuffle id's to keep tx log id's low so we can use u32 for tracking
logged loggers.

7 years agoapp-layer: use logger bits to avoid looping
Victor Julien [Thu, 5 Oct 2017 22:20:44 +0000 (00:20 +0200)] 
app-layer: use logger bits to avoid looping

Avoid looping in transaction output.

Update app-layer API to store the bits in one step
and retrieve the bits in a single step as well.

Update users of the API.

7 years agoapp-layer: register per proto logger bits
Victor Julien [Thu, 5 Oct 2017 19:07:41 +0000 (21:07 +0200)] 
app-layer: register per proto logger bits

Create a bitmap of the loggers per protocol. This is done at runtime
based on the loggers that are enabled. Take the logger_id for each
logger and store it as a bitmap in the app-layer protcol storage.

Goal is to be able to use it as an expectation later.

7 years agodetect: put inspect code for MATCH-list into func 3133/head
Victor Julien [Sat, 7 Oct 2017 13:01:27 +0000 (15:01 +0200)] 
detect: put inspect code for MATCH-list into func

Introduce DetectRunInspectRulePacketMatches to inspect the signatures
match list.

7 years agodetect: move detect cleanup into util func
Victor Julien [Sat, 7 Oct 2017 10:17:39 +0000 (12:17 +0200)] 
detect: move detect cleanup into util func

7 years agodetect: move packet hdr inspect into util func
Victor Julien [Sat, 7 Oct 2017 10:15:03 +0000 (12:15 +0200)] 
detect: move packet hdr inspect into util func

7 years agodetect-ftpdata: register keyword
Eric Leblond [Fri, 5 Jan 2018 15:58:18 +0000 (16:58 +0100)] 
detect-ftpdata: register keyword

Keyword registration was missing so the keyword was not existing.

7 years agorunmodes: fix single runmode bug with pcap
Maurizio Abba [Fri, 5 Jan 2018 18:03:42 +0000 (18:03 +0000)] 
runmodes: fix single runmode bug with pcap

Fix crash for suricata running with pcap option and single runmode.

Ticket: https://redmine.openinfosecfoundation.org/issues/2403

7 years agorust/nfs: improve file close handling
Victor Julien [Tue, 17 Oct 2017 08:19:00 +0000 (10:19 +0200)] 
rust/nfs: improve file close handling

7 years agorust/nfs: don't panic on malformed NFS traffic
Nick Price [Thu, 28 Dec 2017 16:11:17 +0000 (11:11 -0500)] 
rust/nfs: don't panic on malformed NFS traffic

Instead set events.

7 years agoaf-packet: free ring buffer at exit 3130/head
Eric Leblond [Mon, 1 Jan 2018 18:03:24 +0000 (19:03 +0100)] 
af-packet: free ring buffer at exit

7 years agorust/mingw: fix linker issues on mingw
Victor Julien [Thu, 21 Dec 2017 15:25:13 +0000 (16:25 +0100)] 
rust/mingw: fix linker issues on mingw

7 years agocuda: remove 3128/head
Victor Julien [Sat, 30 Dec 2017 13:55:26 +0000 (14:55 +0100)] 
cuda: remove

Remove CUDA support as it has been broken for a long time.

Ticket #2382.

7 years agoscan-build: fix memleak warning in port parsing 3117/head
Victor Julien [Thu, 21 Dec 2017 11:07:46 +0000 (12:07 +0100)] 
scan-build: fix memleak warning in port parsing

7 years agodetect/tos: minor cleanups
Victor Julien [Thu, 21 Dec 2017 11:02:33 +0000 (12:02 +0100)] 
detect/tos: minor cleanups

7 years agodetect/tos: fix memleak in error path
Victor Julien [Thu, 21 Dec 2017 11:00:28 +0000 (12:00 +0100)] 
detect/tos: fix memleak in error path

7 years agoscan-build: simplify FatalErrorOnInit macro
Victor Julien [Thu, 21 Dec 2017 10:10:52 +0000 (11:10 +0100)] 
scan-build: simplify FatalErrorOnInit macro

7 years agoscan-build: don't use memory wrappers
Victor Julien [Thu, 21 Dec 2017 10:01:12 +0000 (11:01 +0100)] 
scan-build: don't use memory wrappers

7 years agoscan-build: fix warning in radix tree
Victor Julien [Thu, 21 Dec 2017 10:00:28 +0000 (11:00 +0100)] 
scan-build: fix warning in radix tree

7 years agoscan-build: fix warning in streaming buffer
Victor Julien [Thu, 21 Dec 2017 09:59:03 +0000 (10:59 +0100)] 
scan-build: fix warning in streaming buffer

7 years agothreads: avoid NULL-ptr deref in thread init wait
Victor Julien [Thu, 21 Dec 2017 09:47:52 +0000 (10:47 +0100)] 
threads: avoid NULL-ptr deref in thread init wait

** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()

________________________________________________________________________________________________________
*** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()
2129         struct timeval cur_ts;
2130         gettimeofday(&start_ts, NULL);
2131
2132     again:
2133         gettimeofday(&cur_ts, NULL);
2134         if ((cur_ts.tv_sec - start_ts.tv_sec) > 120) {
>>>     CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "tv".
2135             SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
2136                     "initialize in time: flags %04x", tv->name,
2137                     SC_ATOMIC_GET(tv->flags));
2138             return TM_ECODE_FAILED;
2139         }
2140

7 years agoRust: fix probing function prototype: change sign and add Flow
Pierre Chifflier [Wed, 29 Nov 2017 11:07:44 +0000 (12:07 +0100)] 
Rust: fix probing function prototype: change sign and add Flow

7 years agomingw: improve ipaddress parsing 3112/head
Victor Julien [Mon, 11 Dec 2017 17:18:28 +0000 (18:18 +0100)] 
mingw: improve ipaddress parsing

7 years agomingw: fix issues in pcap directory code
Victor Julien [Mon, 11 Dec 2017 12:32:47 +0000 (13:32 +0100)] 
mingw: fix issues in pcap directory code

Fix issues with 'stat' and explicitly skip . and ..

7 years agomingw: wrapper for usleep in threads
Victor Julien [Mon, 27 Nov 2017 13:31:45 +0000 (14:31 +0100)] 
mingw: wrapper for usleep in threads

usleep on MinGW doesn't behave as expected. Added replacement
wrapper around 'Sleep(msec)'. As that has msec resolution and
not a usec resolution, change the various thread init and stop
functions to test for the actual time waited instead of counting
the usecs passed to usleep.

7 years agomingw/cygwin: explicitly disable unix socket
Victor Julien [Mon, 27 Nov 2017 08:06:03 +0000 (09:06 +0100)] 
mingw/cygwin: explicitly disable unix socket

7 years agomingw: use c:\Program Files\Suricata for w64
Victor Julien [Mon, 27 Nov 2017 07:51:35 +0000 (08:51 +0100)] 
mingw: use c:\Program Files\Suricata for w64

7 years agoipv6: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:17:57 +0000 (11:17 +0100)] 
ipv6: add string validation function

7 years agoipv4: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:09:19 +0000 (11:09 +0100)] 
ipv4: add string validation function

7 years agodecode/mime: improve ip address validation
Victor Julien [Sun, 26 Nov 2017 08:58:03 +0000 (09:58 +0100)] 
decode/mime: improve ip address validation

inet_pton on Windows/MinGW is very liberal, so do manual validation
of IP address formatting.

7 years agomingw: work around mingw more liberal ip parsing
Victor Julien [Sat, 25 Nov 2017 13:23:35 +0000 (14:23 +0100)] 
mingw: work around mingw more liberal ip parsing

7 years agoconsole: no color for native windows build
Victor Julien [Sat, 25 Nov 2017 09:34:34 +0000 (10:34 +0100)] 
console: no color for native windows build

7 years agomingw: disable pid checking from pidfile
Victor Julien [Mon, 17 Jul 2017 14:20:22 +0000 (16:20 +0200)] 
mingw: disable pid checking from pidfile

kill() call is not supported in MinGW

7 years agomingw: fix 'struct tm' compilation issue
Victor Julien [Mon, 17 Jul 2017 14:19:32 +0000 (16:19 +0200)] 
mingw: fix 'struct tm' compilation issue

7 years agostrptime: add implementation from NetBSD
Victor Julien [Mon, 17 Jul 2017 13:26:43 +0000 (15:26 +0200)] 
strptime: add implementation from NetBSD

As MinGW doesn't come with strptime take the BSD licensed
implementation from NetBSD. More specifically, the one from

https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-libkml/strptime.c

It's slightly modified to get rid on 'uint'.

7 years agomingw: add SCNtohl and SCNtohs macro's
Victor Julien [Mon, 17 Jul 2017 11:45:44 +0000 (13:45 +0200)] 
mingw: add SCNtohl and SCNtohs macro's

On MinGW the result of ntohl needs to be casted to uint32_t and
the result of ntohs to uint16_t. To avoid doing this everywhere
add SCNtohl and SCNtohs macros.