2972 Commits

Author SHA1 Message Date
Art O Cathain
ba0436eb63 Merge remote-tracking branch 'origin/master' into tls-client-sni
# Conflicts:
#	tests/Makefile.am
2017-11-05 14:55:57 +00:00
Rainer Gerhards
18262d01f1
Merge pull request #1965 from rgerhards/cid-185423
file stream handler: ensure multiline read is kept valid
2017-11-05 11:09:45 +01:00
Rainer Gerhards
e54e6f8f38
Merge pull request #1960 from rgerhards/185393
ruleset: "fix" coverity scan issue
2017-11-05 11:09:23 +01:00
Rainer Gerhards
167c57f17e build: remove #pragmas which can cause build issues 2017-11-04 15:28:41 +01:00
Rainer Gerhards
b0d9c79b89 ruleset: "fix" coverity scan issue
while the issue is valid, this was not a bug but rather a
safeguard. Doing it slightly differntly this time.

CID 185393
2017-11-03 19:19:10 +01:00
Rainer Gerhards
a71913029e file stream handler: ensure multiline read is kept valid
We ensure that the previous line segment is always valid... actually this
was already done with existing code, but Coverity scan did not detect this.
Maybe we now get a control flow issue because we do what already happened
in this case...

CID 185423
2017-11-03 19:01:13 +01:00
Rainer Gerhards
4a9fdf172a
Merge pull request #1958 from rgerhards/cid-185378
core/net: potential memory leak when adding AllowedSenders
2017-11-03 18:34:08 +01:00
Rainer Gerhards
6b42e3cf86
Merge pull request #1957 from PascalWithopf/i-1920
Segfault when variable path consists of variables
2017-11-03 18:31:53 +01:00
Rainer Gerhards
355a9f32f2 core/net: potential memory leak when adding AllowedSenders
This is a small static leak that happens during config reading. At
most one leak for each configured but invalid allowed sender.

Detectec by Coverity scan, CID 185378
2017-11-02 17:46:42 +01:00
PascalWithopf
c7a5085a7e Segfault when variable path consists of variables
When no variables exist and a variable with at least one variable in its path was used, then rsyslog was searching for that non existant variable
Rsyslog now aborts it when no variables exist.
closes https://github.com/rsyslog/rsyslog/issues/1920
2017-11-02 17:38:25 +01:00
Rainer Gerhards
debeb5d9cb gcry crypto provider: fix potential NULL pointer addressing
happens only during out of memory condition

Detected by Coverity scan, CID 185422
2017-11-02 13:01:50 +01:00
Rainer Gerhards
ff32dcdb74 dnscache: refactor locking
keep a simple lock ... unlock scheme within the function. That is
easier to follow for both humans as well as static analyzers.

Also removes Coverity scan CID 185419
2017-11-01 19:35:37 +01:00
Rainer Gerhards
7c4adc5598 imdiag bugfix: double mutex unlock
This was caused by double-evaluation of a macro argument; macro changed

Detected by Coverity scan, CID 185348 and 185350
2017-11-01 17:12:54 +01:00
Rainer Gerhards
7b5b00a759 core/msg: refactor locking for json variable access
refactored the method so that it consistent in all functions and easier
to follow. Most importantly, now an as simple as possible locking paradigm
of lock ... unlock within the function. Hopefully easier to understand
both for humans and static code analyzers.
2017-11-01 13:12:57 +01:00
Rainer Gerhards
3f6a8d6b1b core: fix theoretical locking error
could theoretically happen if data structure was corrupted before
entering function. If so, would have lead to double unlock.

This is an experimental "solution" - if it works, we may consider
applying it to other places as well or working on a better one.

Detected by Coverity scan, CID 185469
2017-10-31 13:17:04 +01:00
Rainer Gerhards
3df324aaeb core/msg: potential race in variable handling
Commit 1090c5a68a4da705c91f33a1288610e23b6f3e1d was incomplete, fixing
it with this commit here. See previous commit for more details.
2017-10-31 13:08:39 +01:00
Rainer Gerhards
1090c5a68a core/msg: potential race in variable handling
Root of variable tree is accessed prior to locking access to it.
This introduces a race that may result in various kinds of
misadressing.

Found while reviewing code, no bug report exists.
2017-10-31 11:22:52 +01:00
Rainer Gerhards
8597d15898
Merge pull request #1931 from rgerhards/coverity-8
another set of Coverity scan patches
2017-10-31 10:33:41 +01:00
Rainer Gerhards
a2101e9d52 core/file stream object bugfix: memory leak
If a multiline read errored out, a line buffer could be leaked.

Detected by Coverity scan, CID 185328
2017-10-30 18:53:21 +01:00
Rainer Gerhards
1ae7b72241 file crypto provider: fix potential misadressing and memory leak
If the config parameters were invalid, a misadressing could occur. If so,
this happens only during startup.

Also, a memory leak existed when the crypto provider errored out. This could
build up if it were used in frequently-changing dynafiles. This was
detected by Coverity scan, CID 185360.

Finally some light code simplification (free handling).
2017-10-30 18:53:21 +01:00
Rainer Gerhards
67e6dc3379
Merge pull request #1927 from rgerhards/fix-thread
fix issues seen by clang thread sanitizer
2017-10-30 14:25:25 +01:00
Rainer Gerhards
267cb74580 core/queue: fix potential race in queue shutdown
detected by clang thread sanitizer
2017-10-30 09:56:11 +01:00
Rainer Gerhards
cff20639b7 file encryption: file handle leak
If file encryption was turned on and the state file larger 64K a
file handle leak occured.

Detected by Coverity scan, CID 185383
2017-10-29 19:13:04 +01:00
Rainer Gerhards
e0c0886a6e core/stats: memory leak if sender tracking is enabled
Detected by Coverity scan, CID 185439
2017-10-29 19:13:04 +01:00
Rainer Gerhards
03412875e2 core/stats: memory leak if sender stats are enabled
Detected by Coverity scan, CID 185438
2017-10-29 19:13:04 +01:00
Rainer Gerhards
975ca5fedc core/file stream: fix potential infinite loop
Detected by Coverty scan (albeit as different issue), CID 185328
2017-10-29 19:13:04 +01:00
Rainer Gerhards
573af0da93
Merge pull request #1924 from rgerhards/coverty-6
fixes based on Coverity scan
2017-10-28 18:12:33 +02:00
Rainer Gerhards
bacdc9beb4
Merge pull request #1922 from rgerhards/cid-185330
cosmetic: ensure strmOpenFile() has opened file when returning RS_RET_OK
2017-10-28 18:11:53 +02:00
Rainer Gerhards
4bc24fb952 core/tcp: fix potential buffer overflow
Detected by Coverity scan, CID 182329
2017-10-28 14:30:13 +02:00
Rainer Gerhards
2b5510b074 cosmetic: remove unnecessary cleanup detected by Coverity Scan
This removes what Coverity scan correctly identified as unnecessary.
However, it might have been there to prevent a clang static analyzer
false positive, so we check if this causes issues and merge only
if not. I keep this note in any case because it later might become
important info.

CID 185313
2017-10-28 13:04:47 +02:00
Rainer Gerhards
7933210f7c cosmetic: ensure strmOpenFile() has opened file when returning RS_RET_OK
this tries to fix a potential false positive in Coverity scan. If this does
not work out, we need to explicitely set it to false positive.

CID 185330
2017-10-28 12:58:04 +02:00
Rainer Gerhards
3d1be1fd32
Merge pull request #1918 from rgerhards/coverty-5
fix coverty scan issues
2017-10-28 12:20:06 +02:00
Rainer Gerhards
a0474fd193 apply some more "const" attributes
... while we are at it ;-)
2017-10-28 11:32:42 +02:00
Rainer Gerhards
cbdc147394 file crypto provider: refactor interface
This permits an atomic check for error conditions and helps avoid
inconsistency between check and use of file name, which can also
pose security issues (not in the previous code, as the check was only
used for error-reporting).

Detected by Coverty scan, CID 185400
2017-10-28 11:25:08 +02:00
Rainer Gerhards
67a852846a core/stats: prevent memory leak if stats-callback fails
Detected by Coverty scan, CID 185354
2017-10-28 11:22:01 +02:00
Rainer Gerhards
69587722c7
Merge pull request #1910 from rgerhards/coverty-4
some more Coverty Scan-induced patches
2017-10-28 10:55:44 +02:00
Rainer Gerhards
1310b58e5b core/stats: memory leak in out of memory condition
memleak happens only when there is no memory left at all.

Detected by Coverty scan, CID 185375
2017-10-27 16:14:20 +02:00
Rainer Gerhards
a42e852f64 core: fix potential file handle leak
If files are encrypted via the libgcry crypto provider, file handles
with numerical values 0 obtained by the crypto provider are never
closed. This is extremely unlikely to happen, as file handle 0
is (almost) every time already persistently open when the code
in question is reached.

Detected by Coverty scan, CID 185411.
2017-10-27 13:25:25 +02:00
Rainer Gerhards
bf81d5a9b0 applying some "const" attributes
in trying to get more robust code (we do this as a side-activity
from time to time)
2017-10-27 13:19:51 +02:00
Rainer Gerhards
2b0520fb2b Merge pull request #1908 from rgerhards/coverty-3
core: potential NULL pointer dereference in config parsing
2017-10-27 10:36:26 +02:00
Rainer Gerhards
26ee94a7ef Merge pull request #1904 from rgerhards/coverty-lookup
lookup table bugfix:  potential infinite loop
2017-10-27 10:35:33 +02:00
Rainer Gerhards
8d8bcb1025 Merge pull request #1907 from rgerhards/coverty-2
core: double free under OOM condition (extremely unlikely)
2017-10-27 10:33:16 +02:00
Rainer Gerhards
9074b5ab97 core: potential NULL pointer dereference in config parsing
This happens if there is a problem with the timezone parameters.
Affects only startup, once started, no problem exists.

Detected by Coverty scan; CID 185414
2017-10-26 13:07:13 +02:00
Rainer Gerhards
81a4c779b5 fix Coverty scan "false positive" 2017-10-26 12:15:17 +02:00
Rainer Gerhards
11388ad870 core: double free under OOM condition (extremely unlikely)
Detected by Coverty scan, can only happen when we run out of
memory, in which case we have a very big problem anyhow.

Double free could happen in lower layer when a property was
freed due to realloc failure. Solution is to continue to use
old value, which also makes sense otherwise.
2017-10-26 12:04:00 +02:00
Rainer Gerhards
bc53205a1b lookup table bugfix: potential infinite loop
lookup table could loop if error in lookupDoStub() occurs

also fixes coverty scan CID 185315 (IDENTICAL_BRANCHES due to
CHKiRet() immediately followed by finalize_it)
2017-10-26 11:00:04 +02:00
Rainer Gerhards
cdc5d6bae9 core: potential misadressing when accessing JSON properties
When a JSON property is accessed in template processing, memory
may be misadressed or a double-free may occur while obtaining the
propety.

This was detected by a Coverty scan.
2017-10-26 10:29:13 +02:00
Rainer Gerhards
c5162da8d1 stats bugfix: potential program hang
due to missing unlock. This could only occur if pstats was set to
CEE-format logging (very uncommon) AND if the system runs out of
memory (in which case other things go pretty bad as well).

found by Coverty scan
2017-10-26 10:10:58 +02:00
PascalWithopf
d67f72979e imtcp: change error msg to check for NULL
On Solaris trying to print an empty parameter leads to a Segmentation Fault when the error message, which contains the parameter, is printed.
2017-10-25 11:48:48 +02:00
Rainer Gerhards
eb50a9ebed Merge pull request #1889 from rgerhards/ci-static-analyzer
CI: add script to run static analyzer
2017-10-24 13:58:25 +02:00