3096 Commits

Author SHA1 Message Date
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
Rainer Gerhards
1800103158 Merge pull request #1878 from jgerhards/i1876
queue: enhance error message
2017-10-24 12:00:14 +02:00
Rainer Gerhards
f9f33c7056 core/lookup: fix potential misadressing
found by clang 5.0 static analyzer. The situation is now reported
via an error message indicating internal program error.
2017-10-24 11:23:33 +02:00
Rainer Gerhards
723720d5af work around clang static analyzer false positives 2017-10-24 11:23:33 +02:00
Rainer Gerhards
4798212040 work around clang static analyzer false positives 2017-10-24 11:23:33 +02:00
Rainer Gerhards
69869d5c01 core/nsd_gtls: fix potential unitialized data access
detected by clang 5.0 static analyzer
2017-10-23 15:16:09 +02:00
Rainer Gerhards
4cbebce23d Merge commit 'b8863c2a6a879e54fccae50209ec285ccbe712dd' into merge-961 2017-10-22 15:29:23 +02:00
Jan Gerhards
e03133362c queue: enhance error message
closes https://github.com/rsyslog/rsyslog/issues/1876
2017-10-21 16:17:28 +02:00
Rainer Gerhards
7c273a3314 core: emit error message on abnormal input thread termination
this in almost all cases indicates a real problem that the user
should be made aware of

For a case where the missing error message caused confusion
see also https://github.com/rsyslog/rsyslog/issues/1867
2017-10-20 09:22:45 +02:00
Rainer Gerhards
0f652f42d5 Merge pull request #1864 from rgerhards/gcc7
build: add macro to support new FALLTHROUGH checks in gcc7
2017-10-20 08:29:17 +02:00
Rainer Gerhards
b85f2cc6d5 Merge pull request #1857 from rgerhards/i-1122
core bugfix: potential segfault when shutting down rsyslog
2017-10-19 13:33:18 +02:00
Rainer Gerhards
26ef28cfd2 build: add macro to support new FALLTHROUGH checks in gcc7
We add a macro to provide better cross-platform compatibility.
We also intend to do this for other attribues as well.
2017-10-19 13:09:28 +02:00
Rainer Gerhards
c503c70913 Merge pull request #1855 from rgerhards/i-1838
fix imgssapi
2017-10-19 11:14:09 +02:00
Rainer Gerhards
9dc9a90e3d imgssapi: fix potential memory leak detected by clang static analyzer
... and some cosmetic fixes to remove static analyzer false positives
2017-10-18 19:25:28 +02:00
Rainer Gerhards
3fbd901b3e core bugfix: potential segfault when shutting down rsyslog
when rulesets are nested a segfault can occur when shutting down
rsyslog. the reason is that rule sets are destructed in load order,
which means a "later" ruleset may still be active when an "earlier"
one was already destructed. In these cases, a "call" can invalidly
call into the earlier ruleset, which is destructed and so leads to
invalid memory access. If a segfault actually happens depends on the
OS, but it is highly probable.

The cure is to split the queue shutdown sequence. In a first step,
all worker threads are terminated and the queue set to enqOnly.
While some are terminated, it is still possible that the others
enqueue messages into the queue (which are then just placed into the
queue, not processed). After this happens, a call can no longer
be issued (as there are no more workers). So then we can destruct
the rulesets in any order.

closes https://github.com/rsyslog/rsyslog/issues/1122
2017-10-18 11:00:24 +02:00
Rainer Gerhards
c64a79c0d3 omfwd: provide error message on connect error 2017-10-17 11:04:33 +02:00
Rainer Gerhards
ad040017e8 Merge pull request #1807 from rgerhards/case-sensitive
handle (JSON) variables in case-insensitive way
2017-10-16 11:09:56 +02:00
Rainer Gerhards
78da65a19a Merge pull request #1814 from mrworkman/rscript-format-time
WIP: Add RainerScript format_time() funcion to format UNIX timestamps.
2017-10-16 10:05:09 +02:00
Rainer Gerhards
af52d2ec62 cosmetic: fix (mainly) style issues 2017-10-13 12:29:15 +02:00
Rainer Gerhards
6fe8153be9 handle (JSON) variables in case-insensitive way
The variable system inside rsyslog is JSON based (for easy consumption
of JSON input, the prime source of structured data). In JSON, keys
("variable names") are case-sensitive. This causes constant problems
inside rsyslog configurations. A major nit is that case-insensitivity
option inside templates (even if turned on) does not work with JSON
keys because they of inner workings*1.

It is much more natural to treat keys in a case-INsensitive way (e.g.
"$!Key" and "$!key" are the same). We do not expect any real problems
out of this, as key names only differing in case is highly unlikely.
However, as it is possible we provide a way to enable case-sensitivity
via the global(variables.casesensitve="on") global config object.

Note that the default is to do case-insensitive matches. The reason
is that this is the right thing to do in almost all cases, and we do
not envision any problems at all in existing deployments.

*1 Note: case-insensitivity in rsyslog is achieved by converting all
names to lower case. So that the higher speed of strcmp() can be used.
The template option does actually that, convert the template keys to
lower case. Unfortunately, this does not work with JSON, as JSON keys
are NOT converted to lower case.

closes https://github.com/rsyslog/rsyslog/issues/1805
2017-10-13 09:39:56 +02:00
Rainer Gerhards
3d7223dd25 core: add ability to limit number of error messages going to stderr
This permits to put a hard limit on the number of messages that can
go to stderr. If for nothing else, this capability is helpful for the
testbench. It permits to reduce spamming the test log while still
providing the ability to see initial error messages. Might also be
useful for some practical deployments.

closes https://github.com/rsyslog/rsyslog/issues/1841
2017-10-12 16:14:13 +02:00
Rainer Gerhards
71b0922c22 action handler: detected and handle DATAFAIL error during action processing 2017-10-12 13:26:10 +02:00
Rainer Gerhards
149c23368b action bugfix: no "action suspended" message during retry processing
The action engine does not emit "action suspended" messages but "resumed"
ones in retry processing. This is wrong, as they are a strong indication
that something does not work correctly. Nevertheless, "resumed" messages
were emitted, which was very puzzling for the user.

This patch fixes it so that "suspend" messages are given during retry
processing. These do not contain a retry timestamp, providing evidence
that a retry is currently being tried.

closes https://github.com/rsyslog/rsyslog/issues/1069
2017-10-12 13:26:10 +02:00
Stephen Workman
0ff332ab87 Remove NULL checks. 2017-10-11 17:19:34 -04:00
Stephen Workman
993f2ca187 Remove use of strftime(), for portability reasons. 2017-10-08 17:50:33 -04:00
Rainer Gerhards
8feba89922 debug/cosmetic: remove spamming debug message
... which is actually not needed and only makes the debug
log larger and less readable.
2017-10-07 12:15:41 +02:00
Stephen Workman
7b5b6c2295 Use gmtime, and var2Number. 2017-10-05 21:31:26 -04:00