Commit Graph

4619 Commits (2d25f12cda60ebaf8448f79ff94ee84c2969b329)

Author SHA1 Message Date
Victor Julien 0cf71befbb util-host-os-info: scan-build fix
util-host-os-info.c:202:13: warning: Potential leak of memory pointed to by 'user_data'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
1 warning generated.
12 years ago
Victor Julien a6474bd6bf util-host-os-info: scan build fixes
util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'ip_str'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'user_data'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
2 warnings generated.
12 years ago
Victor Julien 9ef9a14315 Fix util-debug scan-build warnings
util-debug.c:461:12: warning: Potential leak of memory pointed to by 'substr'
    return SC_ERR_SPRINTF;
           ^~~~~~~~~~~~~~
util-debug.c:856:31: warning: Potential leak of memory pointed to by 's'
                op_ifaces_ctx = SCLogInitFileOPIface(s, NULL, SC_LOG_LEVEL_MAX);
                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-debug.c:1349:9: warning: Potential leak of memory pointed to by 's'
    if (log_level >= 0 && log_level < SC_LOG_LEVEL_MAX)
        ^~~~~~~~~
3 warnings generated.
12 years ago
Eric Leblond 0189b4d1eb json file: separate http params
This patch separates http keys from file to have a different value
list:

{
 "time":"01\/31\/2014-12:04:52.837245","event_type":"file","src_ip":"5.3.1.1","src_port":80,"dest_ip":"1.8.1.9","dest_port":9539,"proto":"TCP",
 "http":{"url":"/foo/","hostname":"bar.com","http_refer":"http:\/\/bar.org","http_user_agent":"Mozilla\/5.0"},
 "file":{"filename":"bar","magic":"unknown","state":"CLOSED","stored":false,"size":21}
}

One interest of this modification is that it is possible to use the
same key as the one used in http events. Thus correlating both type
of events is trivial. On code side, this will permit to factorize
the code by simply asking the underlying protocol to output its
info in a json object.

Second interest is that adding file extraction for a new protocol
will result in only changing the protocol specific json list.
12 years ago
Eric Leblond 6fd9b4b255 json: add event_type key
This patch adds an event_type key to the generated events. Current
value is one of "dns", "alert, "file", "tls", "http", "drop". It is
then easy to differentiate in log analysis tools the events based on
source inside Suricata.
12 years ago
Eric Leblond 93a84180dc json dns: do not use array to output answer
Without this patch DNS answers for a single query are stored in a
single json event. The result is an array in the object like this one:
 {"type":"answer","id":45084,"rrname":"s-static.ak.facebook.com","rrtype":"CNAME","ttl":734},
 {"type":"answer","id":45084,"rrname":"s-static.ak.facebook.com.edgekey.net","rrtype":"CNAME","ttl":1710},
This type of output is not well supported in logstash. It is
displayed as it is written above and it is not possible to
query the fields.

I think the reason is that this is not logical if we consider search
query. For example if we search for "rrname" equal "s-static.ak.facebook.com"
we got one entry with two values in it. That's against the logic
of event. Furthermore, if we want to get a complete query, we can
used the id.

This patch splits the answer part in mulitple message. The result
is then accepted by logstash and fields can be queried easily.
12 years ago
Eric Leblond eab0b7fae9 json-dns: sync field names with draft rfc2629
This patch updates DNS field name to be in sync with RFC 2629:
 https://github.com/adulau/pdns-qof
This will allow to easily use Suricata with other passive DNS tools.
12 years ago
Eric Leblond 7a9efd74e4 json: sync key name with CIM
This patch is synchronizing key name with Common Information Model.
It updates key name following what is proposed in:
 http://docs.splunk.com/Documentation/PCI/2.0/DataSource/CommonInformationModelFieldReference
The interest of these modifications is that using the same key name
as other software will provide an easy to correlate and improve
data. For example, geoip setting in logstash can be applied on
all src_ip fields allowing geoip tagging of data.
12 years ago
Victor Julien 31a024c9b5 Various fixes for scan-build warnings 12 years ago
Victor Julien cd7a5ff0ca output: cleanups
Preparation of making output type for json logs configurable.
12 years ago
Victor Julien efd4c42c0a json tls log: rename to output-json-tls 12 years ago
Victor Julien 9950427466 output: check for multiple instances of drop and tls
Both the drop and tls logs are currently not designed to have multiple
instances running. So until that is changed, error out if more than one
instance is started.
12 years ago
Victor Julien 870bb23ff6 json drop log: rename to output-json-drop 12 years ago
Victor Julien 6cecb4e4d2 json dns: rename output-dnslog -> output-json-dns 12 years ago
Victor Julien 5874f52ec6 json: rename output-httplog -> output-json-http 12 years ago
Victor Julien b5ef269b03 json outputs: cleanups
Clean up header files and improve memory handling.
12 years ago
Victor Julien 3fc63d3656 jansson file log: make file log module
Turn the libjansson based file logger into a file module, as a child
of eve-log.
12 years ago
Victor Julien 039f7b3e5f tls json: turn into packet logger
Like log-tls, turn the json tls logger into a packet logger as the
protocol parser is not tx aware.

Make it a child of eve-log as well.
12 years ago
Victor Julien a9eab06593 output: simple name space support for sub modules
To avoid module name clashes, a submode abc of parent xyz, will now
register itself as xyz.abc.
12 years ago
Victor Julien 3a794f7a63 drop-json: make child of eve-log
Make drop json child of eve-log.
12 years ago
Victor Julien f0aa2ed240 json drop log: move into packet module
Move JSON drop log into a full packet module.
12 years ago
Victor Julien 4bd37cc46a log api: use AppProto instead of uint16_t 12 years ago
Victor Julien 52c3d3ad7c log api: convert all names to const
Instead of strdupping all names w/o a need, use const ptrs.
12 years ago
Victor Julien 85335d9cbe alert json: make child of eve-log
Enable alert json for eve-log by registering the module as a sub-
module of eve-log.
12 years ago
Victor Julien 42858647e2 alert-json: make full module out of json alert
Make a full module out of the json alert code in output-json-alert.[ch].
12 years ago
Victor Julien 79771ff570 output: sub-module support for other log api's
Packets:
void OutputRegisterPacketSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
    PacketLogger LogFunc, PacketLogCondition ConditionFunc);

Files:
void OutputRegisterFileSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc);

Filedata:
void OutputRegisterFiledataSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc);
12 years ago
Victor Julien f830cb8026 output: introduce concept of sub-modules
To support the 'eve-log' idea, we need to be able to force all log
modules to be enabled by the master eve-log module, and need to be
able to make all logs go into a single file. This didn't fit the
API so far, so added the sub-module concept.

A sub-module is a regular module, that registers itself as a sub-
module of another module:

    OutputRegisterTxSubModule("eve-log", "JsonHttpLog", "http",
            OutputHttpLogInitSub, ALPROTO_HTTP, JsonHttpLogger);

The first argument is the name of the parent. The 4th argument is
the OutputCtx init function. It differs slightly from the non-sub
one. The different is that in addition to it's ConfNode, it gets
the OutputCtx from the parent. This way it can set the parents
LogFileCtx in it's own OutputCtx.

The runmode setup code will take care of all the extra setup. It's
possible to register a module both as a normal module and as a sub-
module, which can operate at the same time.

Only the TxLogger API is handled in this patch, the rest will be
updated later.
12 years ago
Victor Julien 8c3e71559a dns-json: turn logger to tx api
Convert Json DNS logger into a Tx Logger API logger.
12 years ago
Victor Julien bc71a43e08 http-json: separate module using tx api
Turn HTTP json logger into a Tx Logger API logger.
12 years ago
Victor Julien 4874d5abbb Various compile fixes after rebase with master 12 years ago
Tom DeCanio 18458a14fb json: rebase fixes
- restore json output-file.[ch] as output-json-file.[ch] after rebase conflict
- fix Makefile.am after merge conflict
- some dev-log-api-v4.0 rebase json fallout cleanup
12 years ago
Tom DeCanio 6fd1b31c57 Remaining JSON output pull request comment edits 12 years ago
Tom DeCanio a3d86594dc address most initial JSON pull request comments 12 years ago
Tom DeCanio 55df2d5cdb add "united" drop JSON log 12 years ago
Tom DeCanio 0c067646a8 Add "united" JSON files output 12 years ago
Tom DeCanio 730ee3d721 First cut at "united" file log output in JSON 12 years ago
Tom DeCanio 88a04742c0 JSON output cleanup 12 years ago
Tom DeCanio b4ac0d90a4 remove unused http JSON code 12 years ago
Tom DeCanio a12fa7c4e1 more output JSON cleanup 12 years ago
Tom DeCanio 6974817f72 remove dead JSON DNS output code 12 years ago
Tom DeCanio a44b2b987b JSON output cleanup 12 years ago
Tom DeCanio 3241732e27 rename alert-json.[ch] output-json.[ch] 12 years ago
Tom DeCanio 3bc95c9258 fix compile errors w/o libjansson 12 years ago
Tom DeCanio 8adbc741ba remove unused JSON TMM_*JSON enumerations 12 years ago
Tom DeCanio 07d3b38d3b Add support for JSON output to syslog/unix_stream/unix_dgram 12 years ago
Tom DeCanio 6c1de2115c JSON output cleanup 12 years ago
Tom DeCanio c654b63f6a add united TLS JSON logging 12 years ago
Tom DeCanio 51b7cf1491 add ICMP type and code support to JSON log 12 years ago
Tom DeCanio c8beb9bf9d Support for configuration of JSON http output module 12 years ago
Tom DeCanio 8c95b085c5 Add vlan and pcap_cnt to JSON logs 12 years ago
Tom DeCanio ce6b07b1b9 First cut at united .yaml configuration 12 years ago
Tom DeCanio 11f84d4ff7 beginning of JSON config alignment 12 years ago
Tom DeCanio 280e4bcb61 move some JSON alert work outside of lock 12 years ago
Tom DeCanio 34d04c3104 JSON cleanup 12 years ago
Tom DeCanio 0df6af3a0b Alert/HTTP/DNS JSON output working with Logstash 12 years ago
Tom DeCanio 5543b6eef4 nested json alert output 12 years ago
Tom DeCanio b94b8e03bd cleanup fallout from upstream merge with alert json work 12 years ago
Tom DeCanio 07571367d3 Change JSON alert syslog level to INFO 12 years ago
Tom DeCanio 860523f5bc fix NULL string into JSON in alert-json 12 years ago
Tom DeCanio e9b192fcc0 change srcport->sp dstport->dp 12 years ago
Tom DeCanio 5498654114 Add JSON formatted alert output 12 years ago
Victor Julien 7450f32351 stream: add performance output for stream pools
Add info messages at shutdown that give an indication of pool use
for the various segment and chunk pools.
12 years ago
Victor Julien 84696ebe2a stream: configurable stream chunk prealloc
The stream chunk pool contains preallocating stream chunks (StreamMsg).
These are used for raw reassembly, used in raw content inspection by
the detection engine. The default setting so far has been 250, which
was hardcoded. This meant that in setups that needed more, allocs and
frees would be happen constantly.

This patch introduces a yaml option to set the 'prealloc' value in the
pool. The default is still 250.

stream.reassembly.chunk-prealloc

Related to feature #1093.
12 years ago
Victor Julien fe1c4951f9 stream: silence stream.reassembly.raw message 12 years ago
Victor Julien b5f8f386a3 stream: configurable segment pools
The stream reassembly engine uses a set of pools in which preallocated
segments are stored. There are various pools each with different packet
sizes. The goal is to lower memory presure. Until now, these pools were
hardcoded.

This patch introduces the ability to configure them fully from the yaml.
There can be at max 256 of these pools.

Yaml layout is as follows:

stream:
  reassemble:
    segments:
      - size: 2048
        prealloc: 3000
      - size: 4
        prealloc: 1000
      - size: 1024
        prealloc: 2000

The size is the packet size. The prealloc value indicates how many
segments are set up at startup.

The pools have no limit wrt how many segments can be used of a certain
size. If the engine needs more than the prealloc size, segments are
malloc'd and free'd. The only limit here is the stream.reassemble.memcap.

If the yaml part if omitted, the default values are the same as before.

Feature #1093
12 years ago
Victor Julien b27d03e2f9 log-filestore: convert to FiledataLog API
This patch converts the log-filestore module to use the new
FiledataLog API.
12 years ago
Victor Julien 9ff6608668 Introduce Filedata Logger API
A new logger API for registering file storage handlers. Where the
FileLog handler is called once per file, this handler will be called
for each data chunk so that storing the entire file is possible.

The logger call in the API is as follows:
    typedef int (*FiledataLogger)(ThreadVars *, void *thread_data,
        const Packet *, const File *, const FileData *, uint8_t flags);

All data is const, thus should be read only. The final flags field
is used to indicate to the caller that the file is new, or if it's
being closed.

Files use an internal unique id 'file_id' which can be used by the
loggers to create unique file names. This id can use the 'waldo'
feature of the log-filestore module. This patch moves that waldo
loading and storing logic to this API's implementation. A new
configuration directive 'file-store-waldo: <filename>' is added,
but the existing waldo settings will also continue to work.
12 years ago
Victor Julien b31e0abffe log-filestore: cleanups
Remove unused code.
Make functions static.
Move registration to the bottom.
12 years ago
Victor Julien 3e33ab4f83 log-filestore: tag truncated files as such
Tag truncated files as truncated in the same way log-file does.
12 years ago
Victor Julien 38249398a3 tx-logger: speed up
By bailing out early in case no logger is enabled for the protocol,
a significant speed up is reached.
12 years ago
Victor Julien 078ff0c0cc app-layer: add logger check to API
The new API call:
    int AppLayerParserProtocolHasLogger(uint8_t ipproto,
                                        AppProto alproto)

Returns TRUE if a logger is registered on the ip/alproto pair, and
FALSE otherwise.
12 years ago
Victor Julien 4c024f9658 profiling: add logger api labels 12 years ago
Victor Julien 0e8ad126d7 log-file: convert to file-logger API
Use file logger API.

Also, check if the protocol is HTTP before getting the HTTP
fields.
12 years ago
Victor Julien ee2a8a9cda Introduce 'file' logging API
This patch introduces a new logging API for logging extracted file info.
It allows for registration of a callback that is called once per file:
when it's considered 'closed'.

Users of this API register their Log Function through:
    OutputRegisterFileModule()

The API uses a magic settings globally. This might be changed later.
12 years ago
Victor Julien cef2eb01c5 log-file: cleanups
Make all functions static.
Move registration to the bottom.
12 years ago
Victor Julien fb5b6dd019 prelude: convert to packet logger API
Convert prelude logger to use the packet logger API.
12 years ago
Victor Julien 8623b8f941 prelude: fix configure and cleanup
Fixes configure enabling of prelude. CFLAGS is reset, so the previous
adding of -DPRELUDE was nixed. Using AC_DEFINE now.

Cleanups:
- make functions static
- simplify handling of no prelude support
- move registration to the bottom
12 years ago
Victor Julien b0a9d08267 alert-syslog: convert to packet logger API
Convert Syslog alert logger to packet logger API.
12 years ago
Victor Julien ec20f45916 alert-syslog: cleanup
Remove separate ipv4 and ipv6 registration functions.
Make all functions static.
Move registration function to the bottom.
Simplify OS_WIN32 wrappers usage.
12 years ago
Victor Julien 6c36824d69 alert-pcapinfo: convert to packet logger API
Convert pcap-info to use the packet logger API.
12 years ago
Victor Julien a536e73695 alert-pcapinfo: clean up
Make functions static.
Move registration to the bottom.
12 years ago
Victor Julien 73377048fd alert-debuglog: minor cleanups
Clean up log functions after packet logger conversion. No more
PacketQueue arguments.
12 years ago
Victor Julien cd4796f3ca alert-debuglog: port to packet logger api
Convert AlertDebugLog to Packet logger API. Convert packet args to
const.
12 years ago
Victor Julien 4b57d0272c alert-debug log cleanups
Make all funcs but registration static.
Remove stale registation prototypes.
Move registation func to the bottom.
12 years ago
Victor Julien 504f39adef log-tls: convert to packet logger API
This patch converts log-tls to use the packet logger API. The packet
logger API was choosen as the TLS parser is not transaction aware.

To make sure the state is only logged once, the flag
SSL_AL_FLAG_STATE_LOGGED was added to the parser. This flag is checked
by the condition function, and set at the end of the Logger function.
12 years ago
Victor Julien bcf5c1f2fb log-tls: clean ups
Make all functions static. Remove separate ipv4 and ipv6 registration
functions. Move register function to the bottom so that we no longer
need function prototype declarations.
12 years ago
Victor Julien 28c4083700 dns: convert dns logger to TX logger API
Make sure to use the new logger TX API. For this the transaction
handling was improved as well.
12 years ago
Victor Julien 35aa6c1e66 Convert log-drop to packet logger api. 12 years ago
Victor Julien 15eb4b292d TX logging API: convert HTTP log
Convert the HTTP log to the new TX logging API.
12 years ago
Victor Julien ad70793f78 Introduce TX logging API
This patch introduces a new API for logging transactions from
tx-aware app layer protocols. It runs all the registered loggers
from a single thread module. This thread module takes care of the
transaction handling and flow locking. The logger just gets a
transaction to log out.

All loggers for a protocol will be run at the same time, so there
will not be any timing differences.

Loggers will no longer act as Thread Modules in the strictest sense.
The Func is NULL, and SetupOuputs no longer attaches them to the
thread module chain individually. Instead, after registering through
OutputRegisterTxModule, the setup data is used in the single logging
module.

The logger (LogFunc) is called for each transaction once, at the end
of the transaction.
12 years ago
Victor Julien 4049c2f74c Packet logging API: convert unified2
Convert unified2 alert to new logging API.
12 years ago
Victor Julien d43ac9ae98 Introduce packet logging output API
This patch introduces a new API for outputs that log based on the
packet, such as alert outputs. In converts fast-log to the new API.

The API gets rid of the concept of each logger being a thread module,
but instead there is one thread module that runs all packet loggers.
Through the registration function OutputRegisterPacketModule a log
module can register itself to be considered for each packet.

Each logger registers itself to this new API with 2 functions and the
OutputCtx object that was already used in the old implementation.
The function pointers are:

LogFunc:       the log function

ConditionFunc: this function is called before the LogFunc and only
               if this returns TRUE the LogFunc is called.

For a simple alert logger like fast-log, the condition function will
simply return TRUE if p->alerts.cnt > 0.
12 years ago
Victor Julien 3474c36b54 no-detect: handle protocols that have no logger
If a protocol parser is active without a logger when detection is
disabled, the transaction handling logic would fail. Now it will
return the proper tx id so we can clean up the complete transactions.
12 years ago
Victor Julien f4872a2f08 Add --disable-detection configure option
Add --disable-detection configure option to compile Suricata with
detection disabled.
12 years ago
Victor Julien 6a3621f2fe Error out if -s/-S are used with disable detect
When Suricata is started with --disabled-detection, the -s and -S
options make no sense. So error out.
12 years ago
Victor Julien 3e2205d08f detect-less: disable raw reassembly
When using --disable-detection automatically disable raw stream
reassembly by forcing stream.reassembly.raw to be false.
12 years ago
Victor Julien 5cc880c5c1 detect-less: add log only TX handling function
When running w/o detect, TX cleanup handling needs to ignore the
inspect_id as it's only updated by detect.

This patch introduces a new ActiveTx handler for logging only:
AppLayerTransactionGetActiveLogOnly

If --disable-detection is passed on the commandline, this function
is registered.
12 years ago
Victor Julien 50f5b246db Update main loop to handle detect-less
Update main startup and shutdown loops to work will when detect
is disabled. In this case de_ctx remains NULL.
12 years ago
Victor Julien 0e08f4b6fc update runmodes to handle detect-less
In runmodes setup, consider a NULL de_ctx to mean detect is disabled.
12 years ago
Victor Julien dfda0cd4b6 flow-time: handle detect-less case
Flow timeout code keeps track of thread module running detect, and
fails (hard) if it doesn't find it.

This changeset retrieves the global g_detect_disabled and passes
it to the timeout handling code during setup.
12 years ago
Victor Julien 258778cde4 Introduce g_detect_disabled global
This global will be set to TRUE if detect is disabled. The reason for
adding a global is that there currently is no clean way to pass
configuration options to management threads.
12 years ago
Victor Julien b44ec80590 Add --disable-detection commandline option
Flags the SuriInstance that the detection engine should be disabled.
Actual disabling is not yet implemented.
12 years ago
Victor Julien ef40fe1f31 flow-timeout: change error logic
If FlowForceReassemblyForFlowV2 can't get packets to inject into the
engine, until now it would bail and retry later. In case of resource
starvation issues, this would cause a lot of lock contention, as the
flow manager would try over and over again.

This patch limits FlowForceReassemblyForFlowV2 to one try per flow,
if it fails... bad luck. It will only fail in serious conditions,
which means we must prefer the health of the engine over the proper
inspection of the flow in question.
12 years ago
Victor Julien ad7eff555d app-layer-proto: speed up
AppLayer Proto detection code uses a mix of pattern search and
"probing parsers". The pattern search validates potential matches
using a single pattern search algo. The code was using SpmSearch
for this, but this made it inefficient as it builds a BoyerMoore
context for each search. This lead to significant memory pressure,
especially on high speed/bandwidth boxes.

This patch switches the search calls to BoyerMoore and BoyerMoore-
Nocase directly. This can be done as the ctx' were available already.
12 years ago
Victor Julien 347c0df9c4 app-layer-event: refactor
Move app layer event handling into app-layer-event.[ch].
Convert 'Set' macro's to functions.
Get rid of duplication in Set and SetRaw. Set now calls SetRaw.
Fix potentential int overflow condition in the event storage.
Update callers.
12 years ago
Victor Julien 4ce53753bc app-layer: shrink AppLayerParserState
Change layout to be more efficient, shrinks structure with 8 bytes.
12 years ago
Victor Julien bf6ab333ff stream: use reassembly.memcap for stream chunks
Use the stream.reassembly.memcap for stream chunks (StreaMsg) as well.
12 years ago
Victor Julien 5206928702 stream: in SACK, always decrease memcap on free
We should always decrease the stream memcap on freeing SACK records.
12 years ago
Victor Julien 7a0649f9c4 pool: rename data structure fields to stack
Rename the following fields:
 -    uint32_t alloc_list_size;
 +    uint32_t alloc_stack_size;

 -    PoolBucket *alloc_list;
 +    PoolBucket *alloc_stack;

 -    PoolBucket *empty_list;
 -    uint32_t empty_list_size;
 +    PoolBucket *empty_stack;
 +    uint32_t empty_stack_size;

To reflect that these are in fact, stacks.
12 years ago
Victor Julien ee83809d8e pool: remove tail tracking in alloc list
The list fully acts like a stack now.
12 years ago
Victor Julien 228d1d3980 pool: document some of the Pool:: fields. 12 years ago
Victor Julien 4c9f9db770 pool: update internal counters at the proper time
Only update Pool::outstanding and Pool::allocated in PoolGet when
we are sure both Alloc and Init were successful.
12 years ago
Victor Julien 3c7f6ed876 stream: improve memcap checking
Only the TcpSegment structure would be checked for fitting in the
memcap, not the actual data.
12 years ago
Victor Julien feedb45770 stream: cast memcap checks to uint64_t 12 years ago
Victor Julien a77b9b36e5 app-layer: parser cleanup
Use f->protomap instead of calling FlowGetProtoMapping. Don't use
TcpSession *ssn ptr for anything other than TCP
12 years ago
Victor Julien 54d64a1237 detect: use pflow pointer
Use pflow pointer in SigMatchSignatures consistently. Also, when
needing access to the ipproto, use p->proto, not p->flow->proto.
12 years ago
Victor Julien 634eb1d35c app-layer proto detect: optimization
Don't use FlowGetProtoMapping at runtime, use f->protomap instead.
Add safety check to make sure its value is within range, as it's
used to index an array.

Update unittests to initialized flows (somewhat).
12 years ago
Victor Julien 4f1f395bb5 Coverity 1153935: fix confusing sizeof 12 years ago
Victor Julien 1f00ff6ab3 App-layer proto detect cleanups
Remove unnecessay inlining.
Rename functions with wrong naming scheme. E.g. AllocAppLayer.. instead
of AppLayer..Alloc.
Use AppProto instead of uint16_t.
Convert u16 ipproto cases to u8.
12 years ago
Victor Julien 657b83d238 dns: add event for when memcap is reached
Raise event if state-memcap is reached for a flow.
12 years ago
Victor Julien 9a21a2f64b dns: update counters
This patch updates the DNS counters from the main AppLayer entry
functions. Due to the limited scope of AppLayerThreadCtx some of
the logic had to be implemented in app-layer.c, where it doesn't
belong.
12 years ago
Victor Julien 66f764ce7b dns: register counters
Register dns memory counters.
Keep track of memcap reached conditions, and increment counters for
those.
12 years ago
Victor Julien 09e5ea230a app-layer: update UDP entry function
Update AppLayerHandleUdp to take the ThreadVars pointer as an
argument in prepraration of handling counters in this function.
12 years ago
Victor Julien 5f307acace Pass ThreadVars ptr to various thread init funcs
To be able to register counters from AppLayerGetCtxThread, the
ThreadVars pointer needs to be available in it and thus in it's
callers:

- AppLayerGetCtxThread
- DecodeThreadVarsAlloc
- StreamTcpReassembleInitThreadCtx
12 years ago
Victor Julien b844d4315f dns: add memcap checking
Add memuse tracking and memcap checking to the DNS parsers. Memuse
is tracked globally and per flow (state).

Memcaps are also checked per flow and globally before memory allocs
are done.
12 years ago
Victor Julien 850fac84d6 dns: make DNSTransactionAlloc static 12 years ago
Victor Julien d97e93ea71 dns: add memcap options
Add per state and global memcap option parsing.
12 years ago
Victor Julien 0130a89d52 dns: fix dns configure code
Yaml layout changed. DNS had to be updated to retrievel value
for dns flood from the correct location in the config tree.
12 years ago
Victor Julien 32271bdb66 app-layer-ssl: fix unusual memory leak
In some cases the TLS state pointers to subject and issuerdn could
be overwritten by a new memory allocation, causing us to loose
track of the old.

This has been observed in the case of improper VLAN handling, where
it was suspected that multiple unrelated TLS streams were mangled
together.
12 years ago
Victor Julien 28f14b1ed3 app-layer-ssl: style fixes
Coding style fixes for TLS handshake parser.
12 years ago
Victor Julien b57ac888f8 app-layer-ssl: code cleanup
Don't alloc a void ptr and then cast in every operation. Instead,
alloc a SSLState ptr and only case to void on returning the ptr.
12 years ago
Eric Leblond 7d104fde1d util-device: use safe tailq foreach
The loop is freeing elements so we need to use the safe version
of TIALQ_FOREACH.

This fixes a valgrind error:

 Thread 1 Suricata-Main:
 Invalid read of size 8
    at 0x8E129C: LiveDeviceListClean (util-device.c:167)
    by 0x89B742: main (suricata.c:2284)
  Address 0x8382988 is 24 bytes inside a block of size 40 free'd
    at 0x4C2A70C: free (vg_replace_malloc.c:468)
    by 0x8E1297: LiveDeviceListClean (util-device.c:179)
    by 0x89B742: main (suricata.c:2284)
12 years ago
Victor Julien 84f14438c3 Bug 980: fix HTTP memory cleanup at shutdown
Buffers in per thread HTTP header, client body and server body storage
would be freed based on the usage indicator instead of the size
indicator.

As the usage indicator (e.g. hsbd_buffers_list_len) could be reset
while leaving the memory untouched for later reuse, the free function
would not iterate over all memory blocks.

Removed DrMemory suppressions as well.

Bug #980.
12 years ago
Eric Leblond 82a2dd859b af-packet: fix problem introduced in recent commit
Logic of patch 98e4a14f6d was correct
but implementation is wrong because TP_STATUS_KERNEL is equal to
zero and thus can not be evaluated in a binary operation. This patch
updates the logic by doing two tests.

Reported-by: Alessandro Guido
12 years ago
Anoop Saldanha d06a193012 Remove BUG_ON(1) in app layer event second stage preparation function.
This lets us single out and print rules that result in a failure, than
just post a core dump.
12 years ago
Ken Steele 92a821cdd9 Fix make distcheck for Tile
src/Makefile.am was missing util-mpm-ac-tile-small.c which caused
release tarballs for fail to build on Tile-Gx.
12 years ago
Victor Julien 9952db6d6e Fix crash in AppLayer Proto Detect
The App Proto Detect code would use the wrong pattern count to
index a results array, leading to SEGVs.

Bug #1080.
12 years ago
Victor Julien 2eeddf969d Cygwin: fix compilation
tm-threads.c:1190:5: error: unknown type name ‘DWORD’
12 years ago
Victor Julien 2f14d1e94e Fix compiler warning:
array subscript has type ‘char’ [-Werror=char-subscripts]
12 years ago
Victor Julien 0d280e88d0 pool thread: undo CLS alignment
This breaks clang on 32bit.

Test PoolThreadTestGrow01                                         : process killed by signal 11
12 years ago
Victor Julien d5fdfa4bc1 Fix unittest size_t printing on 32bit 12 years ago
Victor Julien 9b736b6b9e dns: tag each tx we get a reply for as replied
Also, detect and print when server says recursion is desired.
12 years ago
Victor Julien 2047e72cbe DNS: don't store duplicate queries
When an exact duplicate DNS query is received, don't store it in the
tx.
12 years ago
Victor Julien e1e2ebe2da memcmp: convert all pointer arguments to be const pointers, like memcmp itself uses. 12 years ago
Victor Julien a9bf939441 dns log: cleanups 12 years ago
Victor Julien b2d420bed4 app-layer: API calls to check for TX aware proto
Introduce AppLayerParserProtocolIsTxAware which returns 1 if protocol
is Tx aware, 0 if not.
12 years ago
Ken Steele 1f99096b30 Fix PmqSetup() argument removal in ac-tile MPM unit tests.
Needed to remove the second argument from all the calls, which was always 0
and was removed in other tests in a previous checkin.
12 years ago
Victor Julien 399246881d counters: fix 2 scan-build warnings
counters.c:1069:13: warning: Potential leak of memory pointed to by 'temp'
            SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./threads.h:121:28: note: expanded from macro 'SCMutexUnlock'
                           ^~~~~~~~~~~~~~~~~~~~
counters.c:1156:16: warning: Potential leak of memory pointed to by 'pca'
        return NULL;
               ^~~~
/usr/include/clang/3.3/include/stddef.h:77:24: note: expanded from macro 'NULL'
                       ^
2 warnings generated.
12 years ago
Victor Julien 2c857087fb app-layer: configurable GetActiveTxId function
In preparation of a patchset that will allow for disabling the detect
module, this patch introduces a way to register a function for getting
the lowest active tx id. This is used by the app layer for cleaning up
transactions that already fully inspected, and by the flow timeout code
to determine if a flow is fully inspected and logged at timeout.

The registration function RegisterAppLayerGetActiveTxIdFunc allows for
registration of a custom function of type:
  uint64_t (*GetActiveTxIdFunc)(Flow *f, uint8_t flags);

If no function is called, AppLayerTransactionGetActiveDetectLog is used,
which implements the existing behaviour of considering both the
inspect_id's and the log_id.
12 years ago
Victor Julien c06c595c56 Clean up TX clean up
In AppLayerTransactionsCleanup instead of figuring out 'done' tx id's
itself, now call AppLayerTransactionGetActive for both directions to
figure out the completed TX id's.
12 years ago
Victor Julien 6e389a1fbb stream: don't send empty streammsg at stream end
No longer send an empty StreamMsg through the engine on stream end,
the messages were ignored anyway.
12 years ago
Victor Julien eb1f5ce358 stream: increase max StreamMsg data
Increase from 4024 bytes to 4072 to make the whole structure
4096 again.
12 years ago
Victor Julien c801ef3515 stream: remove flags from StreamMsg 12 years ago
Victor Julien 261881fce2 stream: remove per thread queue for stream msgs
StreamMsgs would be stored in a per thread queue before being
attached to the tcp ssn. This is unnecessary, so this patch
removes this queue and puts the smsgs into the ssn directly.

Large patch as it affects a lot of tests.
12 years ago
Victor Julien b159c1714c stream: remove flow reference from StreamMsg
StreamMsg' flow reference was used mostly to make sure a flow would
not get removed from the hash before inspection. For this it needed
to reference the flow use_cnt reference counter. Nowadays we have
more advanced flow timeout handling. This will make sure that if
there still are pending smsgs' in a flow, these will still be
processed.
12 years ago
Victor Julien 1d08a3ff26 stream: pass TcpSession to StreamTcpReassembleProcessAppLayer
Preparation for removing flow pointer from StreamMsg. Instead of
getting the ssn indirectly through StreamMsg->flow, we pass it
directly as all callers have it already.
12 years ago
Victor Julien 0ec375d95a stream msg: remove structure 12 years ago
Victor Julien 5ca0139cbc stream: remove unused gap structure from StreamMsg. 12 years ago
Victor Julien 3804f3f1b3 stream: no longer process STREAM_GAP smsgs
StreamSmgs are used for raw stream reassembly only. They could also
be used to tell the rest of the engine about sequence gaps. This was
a left over from the older implementation, where the app layer used
the smsgs as well.
12 years ago
Jason Ish 5850607fea Remove the old include support. 12 years ago
Ken Steele 3a9a14711a Correct coding style in decode-ethernet.c
This file is given as the example of correct coding style, so make sure it
follows the coding standard.
12 years ago
Eric Leblond 7561da4b87 debug: default logging level is notice
Update the string in message because default logging level is
now notice and not info.
12 years ago
Eric Leblond d6932f90db doxygen: document some functions 12 years ago
Eric Leblond e5e390a0c6 Add missing UNITTESTS
There is no need for test functions to be build in normal code.
12 years ago
Eric Leblond 98e4a14f6d af-packet: update packet reading loop logic
This patch updates the logic of the packet acquisition loop. When
the reader loop function is called and when the data to read
at offset is a without data (kernel) or still used by suricata. We
try to iter for a loop on the ring to try to find kernel put by
data.
As we are entering the function because the poll said there was some
data. This allow us to jump to the data added to the ring by the
kernel.
When using suricata in autofp mode, with multiple detect threads and
packet acquisition threads attached to a dedicated CPU, the reader
loop function was looping really fast because poll call was returning
immediatly because we did read the data available.
12 years ago
Eric Leblond 4d6b48ea9e htp layer: add memory cap counter
This patch adds a memcap counter for HTP memory usage. Counter
is increased each time an allocation is not done due to the memcap.
12 years ago
Eric Leblond d6d8a08a8f htp layer: add memory usage counter
This patch adds a memory counter for HTP memory usage. As
there is no thread variables available in application layer
the counter has been added to the TCP reassembly thread.
12 years ago
Eric Leblond ced01da822 htp layer: use memcap for HTTP related allocations
This patch introduces wrapper functions around allocation functions
to be able to have a global HTP memcap. A simple subsitution of
function was not enough because allocated size needed to be known
during freeing and reallocation.

The value of the memcap can be set in the YAML and is left by default
to unlimited (0) to avoid any surprise to users.
12 years ago
Ken Steele ba4758d033 Port unittest from bug #970 for util-mpm-ac.c to util-mpm-ac-tile.c
Passes on ac-tile too.
12 years ago
Ken Steele 326d5d3e15 Add 8-bit states to ac-tile
When running with sgh-mpm-context: full, many more MPMs are created
(16K) and many are small. If they have less than 128 states, they only
need 1 byte for the next state instead of 2 bytes, cutting the size of
the next-state table in half. This reduces total memory usage.

Since that makes 3 different state sizes (1, 2 and 4 bytes), rather
than going from 2 copies of the code to create the MPM to 3, I
factored out the code that fills the next-state table into three
functions so that all the other code could be the same.

The search function is now parameterize for 8-bit and 16-bit state
sizes and alphabet sizes 8, 16, 32, 64, 128 and 256.
12 years ago
Eric Leblond c115e63dc2 pfring: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by pfring. This patch fixes
this by using counter provided by kernel instead.

Pfring kernel counter is per socket and is not cleared after read.
So to get the number of packet on the interface we can add the new
value for this thread and add it to the interface counter.
12 years ago
Eric Leblond 1869688fb8 af-packet: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by kernel. This patch fixes
this by using counter provided by kernel instead.
The counter is Clear On Read, so by adding the value fetch at each call
and earch sockets we get the number of packets and drops for the
interface.
12 years ago
Eric Leblond afbb2eb32b capture: display exit stats at default verbosity
This patch updates capture modes not using LiveDecice counters
to display per-thread exit statistics with default verbosity.
12 years ago
Eric Leblond a8c787a265 device list: clean and display stat at exit
This patch adds a cleaning function to device list. This also
permits to display per-interface statistics during the exit.
12 years ago
Duarte Silva aa6b5b406d Fix the segmentation fault while logging the host on the custom HTTP logger.
- Seems to be a regression introduced in the commit
  796bfab231 (fix was already done in commit
  ee0b21652b)
- Doesn't happen with htplib v0.5.6, but it does in the latest, v0.5.9
12 years ago
Eric Leblond 8a5a30ba40 fix size_t printing
This two problem were found by the new version of the size_t cocci
test.
12 years ago
Victor Julien 446e68adca app-layer: only typedef opaque pointers once 12 years ago
Victor Julien 3b8e9ffbe9 app layer: void -> AppLayerProtoDetectThreadCtx
User AppLayerProtoDetectThreadCtx ptr instead of void.
12 years ago
Victor Julien 8dbf7a0d78 Update tests to use AppLayerParserThreadCtx ptr instead of void. Fix a few bugs uncovered by this. 12 years ago
Victor Julien 9634e60e7a app-layer: Use opaque pointers instead of void
For AppLayerThreadCtx, AppLayerParserState, AppLayerParserThreadCtx
and AppLayerProtoDetectThreadCtx, use opaque pointers instead of
void pointers.

AppLayerParserState is declared in flow.h as it's part of the Flow
structure.

AppLayerThreadCtx is declared in decode.h, as it's part of the
DecodeThreadVars structure.
12 years ago
Victor Julien c7ae662d26 Fix HTPBodyReassemblyTest01 Asan error
Fix improper pointer assignment in HTPBodyReassemblyTest01, causing
ASAN to error out.
12 years ago
Victor Julien fdefb65be4 app-layer: rename AppLayerThreadCtx funcs
AppLayerParserGetCtxThread -> AppLayerParserThreadCtxAlloc
AppLayerParserDestroyCtxThread -> AppLayerParserThreadCtxFree
12 years ago
Victor Julien 0bac43a1ca app layer: fix memory leak
Actually free the ctx in AppLayerParserDestroyCtxThread
12 years ago
Victor Julien f5f148805c app layer: uint16_t alproto -> AppProto alproto
This conversion was missing in a couple of places.
12 years ago
Victor Julien 5cdeadb33d Use u8 for ipproto
In a few places in app layer and unittests u16 was used.
12 years ago
Victor Julien 8527b8e08e App Layer: cleanup state func naming
Rename functions related to AppLayerState to be more consistent.
12 years ago
Victor Julien 30f16ee446 Rename AppLayerProtoDetectCtxThread -> AppLayerProtoDetectThreadCtx 12 years ago
Victor Julien cd0627cd39 Rename AppLayerParserParserState -> AppLayerParserState 12 years ago
Victor Julien c23742a0a7 Rename AppLayerParserpCtx -> AppLayerParserProtoCtx 12 years ago
Victor Julien 72a1645979 Rename AppLayerParserCtxThread -> AppLayerParserThreadCtx 12 years ago
Victor Julien ac77cd790f Rename AppLayerCtxThread -> AppLayerThreadCtx 12 years ago
Victor Julien e111401c10 detect unittests: clang build fix and cleanups
A number of unittests would lead to clang build errors because
of unsafe det_ctx ptr usage. This patch fixes these and inits
det_ctx to NULL in the other detect tests.
12 years ago
Victor Julien e2f7226569 App Layer: fix memory leaks
Call FlowCleanupAppLayer before setting f->proto to 0, as the former
bails out without doing anything if proto is 0.
12 years ago
Victor Julien 67053e6ed0 Fix AppLayerProtoDetectPMFreeSignature related valgrind errors 12 years ago
Victor Julien ff16d6fa53 app proto detect: fix valgrind test warnings
Only in unittests when debug is enabled would valgrind warn about
a print statement.
12 years ago
Victor Julien a456bd8181 Cleanup and fix scan-build warning
Add comments and slightly refactor to make function more understandable
and fix a scan-build warning too.
12 years ago
Victor Julien 8801585f10 scan-build fixes 12 years ago
Victor Julien 106e1c7d19 profiling: fix compilation
Stream engine can't access app layer proto detection datatypes
anymore, so moved some of the logic into app-layer.c
12 years ago
Victor Julien 1cbd1cdf36 compile fixes 12 years ago
Victor Julien 59327e0fd4 Various style fixes 12 years ago
Anoop Saldanha 429c6388f6 App layer API rewritten. The main files in question are:
app-layer.[ch], app-layer-detect-proto.[ch] and app-layer-parser.[ch].

Things addressed in this commit:
- Brings out a proper separation between protocol detection phase and the
  parser phase.
- The dns app layer now is registered such that we don't use "dnstcp" and
  "dnsudp" in the rules.  A user who previously wrote a rule like this -

  "alert dnstcp....." or
  "alert dnsudp....."

  would now have to use,

  alert dns (ipproto:tcp;) or
  alert udp (app-layer-protocol:dns;) or
  alert ip (ipproto:udp; app-layer-protocol:dns;)

  The same rules extend to other another such protocol, dcerpc.
- The app layer parser api now takes in the ipproto while registering
  callbacks.
- The app inspection/detection engine also takes an ipproto.
- All app layer parser functions now take direction as STREAM_TOSERVER or
  STREAM_TOCLIENT, as opposed to 0 or 1, which was taken by some of the
  functions.
- FlowInitialize() and FlowRecycle() now resets proto to 0.  This is
  needed by unittests, which would try to clean the flow, and that would
  call the api, AppLayerParserCleanupParserState(), which would try to
  clean the app state, but the app layer now needs an ipproto to figure
  out which api to internally call to clean the state, and if the ipproto
  is 0, it would return without trying to clean the state.
- A lot of unittests are now updated where if they are using a flow and
  they need to use the app layer, we would set a flow ipproto.
- The "app-layer" section in the yaml conf has also been updated as well.
12 years ago
Anoop Saldanha 127ef8f903 Use a typdef AppProto <-> uint16_t for representing app layer protocol.
Some minor refactoring/cleanup, including renaming functions.
12 years ago
Anoop Saldanha abded4200a Disabling the ssh parser temporarily, since we are moving away from some
of the archaic features we use in the app layer. We will reintroduce this
parser shortly. Also do note that keywords that rely on the ssh parser
would now be disabled.
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.
12 years ago
Victor Julien 3714925d2b stream: fix potential memory loss on error
Coverity 1139543.

If StreamTcpPseudoPacket would be called with len == 0, the packet
it acquired before checking the len value would be lost.
12 years ago
Victor Julien 1cce207c05 Revert TmqhFlowMode alignment as it breaks on CLANG 12 years ago
Victor Julien 9874c1a83b realloc error handling: remove unnecessary else branch 12 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;
+ }
...+>

}
12 years ago
Victor Julien 5e1f1ee4ff Fix filemagic unittests on OS_DARWIN 12 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 *.
12 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.
12 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
12 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.
12 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;
12 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;
12 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;
12 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;
12 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.
12 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;
12 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);
12 years ago
Victor Julien 6709fdd8cf log-http: fix compiler warning
log-httplog.c:180: warning: 'cvalue' may be used uninitialized in \
this function
12 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
12 years ago
Ken Steele 12ab6f3ab4 Fix uninitialized variable warning.
These two lines reported warnings with -Werror -O3 on Tile.
12 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.
12 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.
12 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.
12 years ago
Victor Julien b61552482c mpipe code cleanup: indent fixes 12 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.
12 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.
12 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.
12 years ago
Eric Leblond 58eb6428d1 suricata: ignore SIGHUP signal
This patch ignores the SIGHUP signal instead of having the default
behavior.
12 years ago
Victor Julien 4fdd1a7a71 Fix compilation on systems that use the fallback SC_ATOMIC_ API. 12 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.
12 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.
12 years ago
Victor Julien b770fd2981 http header: improve realloc failure checking. Bug #1062. 12 years ago
Victor Julien 90cf8d4c6e port parsing: improve memory handling 12 years ago
Victor Julien b79b2fff25 cppcheck: add special BUG_ON so cppcheck understands we exit 12 years ago
Victor Julien d5db0cc033 port: don't lead memory on port parsing failure
[src/detect-engine-port.c:1354]: (error) Memory leak: gh
12 years ago
Victor Julien 435f99409f Fix small memleak in runmode setup
[src/runmodes.c:338]: (error) Memory leak: custom_mode
12 years ago
Victor Julien 86aad660a2 threading setup: fix small mem leak on failure
[src/tm-threads.c:1058]: (error) Memory leak: slot
12 years ago
Victor Julien b4631794a8 Fix realloc error handling in threshold.config file parsing. Bug #1062. 12 years ago
Victor Julien 35298a0146 Use %u for unsigned int in (console) output 12 years ago
Victor Julien a9d754c23d Use %u for unsigned ints in checksum warning 12 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.
12 years ago
Victor Julien 5ba898b738 cppcheck: don't use likely/unlikely when -DCPPCHECK is passed to the checker 12 years ago
Victor Julien b2c4a50e39 Fix small memory leak in classtype parsing 12 years ago
Victor Julien fe46c26e4e cppcheck: improve reporting cppcheck when passing -DCPPCHECK to the checker. 12 years ago
Victor Julien afb48cfcb5 log-http: fix error check leading to null-deref on malloc failure during setup 12 years ago
Victor Julien 4165bf8951 log-http: enforce hostname print limit 12 years ago
Victor Julien 1476db44d9 Convert Flow macros to inline functions
Convert FlowReference and FlowDeReference to inline functions for
better readability and to aid static code analyzers.
12 years ago