Commit graph

11634 commits

Author SHA1 Message Date
Tim Wojtulewicz
0f8f53808e Use bools instead of single-bit bitfields in Ident and TCP protocol analyzers 2020-01-07 12:07:58 -07:00
Tim Wojtulewicz
9d38419e8a Bit of code-modernization cleanup in BroString
- Convert single-bit bit fields into bools
- Use bool for a number of function arguments that were previously ints
- Use delegated constructors to reduce repetition in the other constructors
2020-01-07 11:48:52 -07:00
Tim Wojtulewicz
a463c5763f Use fixed types in NetbiosSSN.h and Timer.h instead of bit fields 2020-01-07 11:48:52 -07:00
Jon Siwek
b114766205 Add Supervisor::is_supervised()
And use to to avoid redef'ing the log rotation postprocessor to
"archive-log" by default since it's unlikely PATH is configured to find
that script.
2020-01-07 10:27:07 -08:00
Jon Siwek
aaa702fb4d Add option to change supervised node's working directory 2020-01-06 18:39:14 -08:00
Jon Siwek
0c55b01ec9 Merge remote-tracking branch 'origin/topic/timw/fix-x509-build-warning'
* origin/topic/timw/fix-x509-build-warning:
  Fix build warning in X509 plugin
2020-01-06 16:46:17 -08:00
Tim Wojtulewicz
a20c3a195a Fix build warning in X509 plugin 2020-01-06 15:38:28 -07:00
Jon Siwek
d581aa76aa Merge remote-tracking branch 'origin/topic/dev/patterns-in-sets'
Fixes in merge:
- Memory leak in HashKey ctor
- Minor whitespace/style changes

* origin/topic/dev/patterns-in-sets:
  Enable Patterns as Table index in non singleton cases
  Added support to create a Hashkey for PatternVals using their Pattern Texts
2020-01-06 14:15:30 -08:00
Tim Wojtulewicz
71e6893441 Merge remote-tracking branch 'origin/topic/jsiwek/fix-hexdump-warning'
* origin/topic/jsiwek/fix-hexdump-warning:
  Fix snprintf compiler warning in hexdump BIF
2020-01-06 14:16:55 -07:00
Jon Siwek
99faaf811d Fix snprintf compiler warning in hexdump BIF 2020-01-06 12:29:03 -08:00
Jon Siwek
50d91b17de Updating submodule(s).
[nomail]
2020-01-06 11:50:09 -08:00
Jon Siwek
149d3b4828 Increase a timeout for a btest 2020-01-06 11:20:30 -08:00
Jon Siwek
0cde6d2af5 Fix Cirrus CI FreeBSD python dependencies installation 2020-01-06 10:51:17 -08:00
Jon Siwek
f1be24c4c1 Update submodules 2020-01-06 10:49:09 -08:00
Tim Wojtulewicz
65a4e36a92 Merge remote-tracking branch 'origin/topic/jsiwek/asan'
* origin/topic/jsiwek/asan: (28 commits)
  Increase timeout for a btest
  Switch CI scripts to use ASAN/LSAN instead of gperftools
  Remove redundant memory leak btests
  Fix reference counting issues related to lambdas/closures
  Disable LeakSanitizer for btests that have known leaks
  Rewrite the btest for when-statement timeouts
  Fix memory leak when a logging plugin hook prevents a write
  Fix memory leaks in various input framework error-handling cases
  Fix memory leak in Reporter::get_weird_sampling_whitelist() BIF
  Fix reference counting of Log::Filter "config" field
  Fix memory leak in system_env() BIF
  Clean up triggers awaiting global state modification at shutdown
  Fix memory leak in initializing log writers with no local backend
  Fix packet filter memory leaks
  Skip sending thread heartbeat if it alread asked to be finished
  Fix memory leak of sqlite input reader prepared statement
  Prevent duplicate "finish" threading messages
  Fix memory leak when table-based input stream overwrites old entries
  Fix scripting error in a DHCP btest
  Fix memory leaks in Kerberos ticket decryption
  ...
2020-01-06 11:20:47 -07:00
Jon Siwek
a4fab5327a Merge remote-tracking branch 'origin/topic/timw/util-unit-tests'
* origin/topic/timw/util-unit-tests:
  fixup! Add unit tests to util.cc and module_util.cc
  Mark safe_snprintf and safe_vsnprintf as deprecated, remove uses of them
  Add unit tests to util.cc and module_util.cc
2020-01-06 09:44:43 -08:00
Jon Siwek
a1377e1d42 Increase timeout for a btest
May be more timing-sensitive with slower ASAN/LSAN configuration in
addition to already-slower CI environment.
2020-01-02 23:04:22 -08:00
Jon Siwek
38505589e1 Switch CI scripts to use ASAN/LSAN instead of gperftools
Using AddressSanitizer/LeakSanitizer is better.  It covers the full
unit/baseline test suite by default without requiring one to write
specific memory leak tests.  It also covers other types of memory errors
besides just leaks.
2020-01-02 23:04:22 -08:00
Jon Siwek
e6f4e01041 Remove redundant memory leak btests
Or otherwise convert into a regular btest if it didn't already seem to
be covered.

There's no need for a separate memory leak test group since compiling
with LeakSanitizer now covers leak checking for the full btest suite.
2020-01-02 23:04:22 -08:00
Jon Siwek
44d922c4b5 Fix reference counting issues related to lambdas/closures
For example, circular references between a lambda function the frame
it's stored within and/or its closure could cause memory leaks.

This also fixes other various reference-count ownership issues that
could lead to memory errors.

There may still be some potential/undiscovered issues because the "outer
ID" finding logic doesn't look quite right as the AST traversal descends
within nested lambdas and considers their locals as "outer", but
possibly the other logic for locating values in closures or cloning
closures just works around that behavior.
2020-01-02 23:04:22 -08:00
Tim Wojtulewicz
b3e72a342f fixup! Add unit tests to util.cc and module_util.cc 2020-01-02 16:30:18 -07:00
Tim Wojtulewicz
67fcc9b5af Mark safe_snprintf and safe_vsnprintf as deprecated, remove uses of them
safe_snprintf and safe_vsnprintf just exist to ensure that the resulting strings are always null-terminated. The documentation for snprintf/vsnprintf states that the output of those methods are always null-terminated, thus making the safe versions obsolete.
2020-01-02 15:36:39 -07:00
Tim Wojtulewicz
6a52857f8f Add unit tests to util.cc and module_util.cc 2020-01-02 15:36:39 -07:00
Jon Siwek
0fe2a14d98 Disable LeakSanitizer for btests that have known leaks
E.g. ones that throw interpreter exceptions,  as those are currently
known to potentially cause leaks.  Fixing the underlying leaks involves
the larger task of more IntrusivePtr usage.

Reference cycles may also cause leaks.
2020-01-02 12:05:49 -08:00
Jon Siwek
d917737766 Rewrite the btest for when-statement timeouts
To avoid a memory leak in DNS lookups that's hard to work around and
does not otherwise effect typical operation when Zeek is allowed to
continue to run after zeek_init().
2020-01-02 12:05:49 -08:00
Jon Siwek
09578c6176 Fix memory leak when a logging plugin hook prevents a write 2020-01-02 12:05:49 -08:00
Jon Siwek
6f5f7df970 Fix memory leaks in various input framework error-handling cases 2020-01-02 12:05:49 -08:00
Jon Siwek
3b6a2a5f4e Fix memory leak in Reporter::get_weird_sampling_whitelist() BIF 2020-01-02 12:05:49 -08:00
Jon Siwek
bf05add542 Fix reference counting of Log::Filter "config" field
Which can potentially be a minor memory leak if there's a lot of dynamic
adding/removing of logging filters.
2020-01-02 12:05:49 -08:00
Jon Siwek
273eb19ff5 Fix memory leak in system_env() BIF 2020-01-02 12:05:49 -08:00
Jon Siwek
9e494452f1 Clean up triggers awaiting global state modification at shutdown
Otherwise they can be reported as memory leaks since no more global
state modifications will take place to notify the trigger to clean
itself up.
2020-01-02 12:05:49 -08:00
Jon Siwek
5e73949327 Fix memory leak in initializing log writers with no local backend 2020-01-02 12:05:49 -08:00
Jon Siwek
a961f0b4c4 Fix packet filter memory leaks 2020-01-02 12:05:49 -08:00
Jon Siwek
7db84dfcb6 Skip sending thread heartbeat if it alread asked to be finished
Otherwise the heartbeat message may fail to be processed and show up as
leaked memory.
2020-01-02 12:05:49 -08:00
Jon Siwek
13831ca21b Fix memory leak of sqlite input reader prepared statement 2020-01-02 12:05:49 -08:00
Jon Siwek
9e07b8a9f1 Prevent duplicate "finish" threading messages
As they don't get processed and may show up as a memory leak.
2020-01-02 12:05:49 -08:00
Jon Siwek
3742e5601c Fix memory leak when table-based input stream overwrites old entries 2020-01-02 12:05:49 -08:00
Jon Siwek
d936607cc9 Fix scripting error in a DHCP btest 2020-01-02 12:05:49 -08:00
Jon Siwek
53fadb2bb0 Fix memory leaks in Kerberos ticket decryption
Memory allocated to the decrypted ticket data as well as the server
principal were not freed.

Also fixed potential leaks in error cases that called
krb5_get_error_message() without freeing the returned value.
2020-01-02 12:05:49 -08:00
Jon Siwek
10473d58a9 Fix scripting error in an ftp btest 2020-01-01 12:47:39 -08:00
Jon Siwek
aa0b521597 Update paraglob submodule 2020-01-01 12:47:39 -08:00
Jon Siwek
c0d6eb9efb Fix malloc/delete mismatch in JSON formatting
ODesc allocated with malloc() and BroString deallocated with delete[],
but really the intermediate BroString wasn't even needed when copying
into std::string.
2020-01-01 12:47:39 -08:00
Jon Siwek
8cdcfad6d2 Delete/timeout pending DNS requests during shutdown
Primarily, this change prevents the pending requests showing up as
memory leaks.
2020-01-01 12:47:39 -08:00
Jon Siwek
2fbcf23f76 Fix memory leak in OCSP parsing functions
Various OCSP parsing functions used in presence of OpenSSL 1.1 used
"d2i_ASN1_SEQUENCE_ANY" which returns a "STACK_OF(ASN1_TYPE)", but used
"sk_ASN1_TYPE_free" instead of "sk_ASN1_TYPE_pop_free" to free it.  The
former only frees the stack structure while the later frees both the
structure and the elements.
2020-01-01 12:47:39 -08:00
Jon Siwek
bf90587cb8 Free the global X509 certificate root store on shutdown
Otherwise LeakSanitizer reports its contents as leaked.
2020-01-01 12:47:39 -08:00
Jon Siwek
447c3712cf Add general LeakSanitizer macros/instrumentation 2020-01-01 12:47:39 -08:00
Jon Siwek
4735165d31 Improve --sanitizers configure option
* Rename SANITIZERS CMake variable to ZEEK_SANITIZERS for clarity

* Use -O1 by default to improve speed (set NO_OPTIMIZATIONS env. var.
  to override and use -O0).  Uses -fno-optimize-sibling-calls with -O1
  to still get "perfect stack traces".

* Updates various sub-projects with sanitizer improvements:
  binpac and bifcl, by default, now ignore leaks reported by LeakSanitizer
  so that it doesn't interfere with the Zeek build
2019-12-30 14:09:26 -08:00
Robin Sommer
f6a1a7053b Updating submodule. 2019-12-20 07:53:28 +00:00
Dev Bali
4002a1124e Enable Patterns as Table index in non singleton cases 2019-12-19 19:32:55 -08:00
Dev Bali
a907732e25 Added support to create a Hashkey for PatternVals using their Pattern Texts 2019-12-19 19:32:55 -08:00