77 Commits

Author SHA1 Message Date
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
d5b45c0f5f
Merge pull request #5748 from rgerhards/i1255
scripting: add endswith operator to property filters and RainerScript
2025-07-11 16:58:00 +02:00
Rainer Gerhards
64f683d92b
tooling: new developer tool to fix trailing spaces
This may be an interim solution, but definitely a useful one
to address style inconsistencies.

Style inconsistencies are problematic as they tend to pollute
git history by causing pseudo-changes.

This commit also contains a set of fixes to existing files, so
that we get to a clean state.
2025-07-11 09:01:03 +02:00
Rainer Gerhards
6c9332b2e0
scripting: add endswith operator to property filters and RainerScript
This Implements suffix comparison similar to startswith. Note that we
do intentionally not use libestr functions in order to speed up adaption.
It would otherwise probably take years for distros to upgrade libestr.

With some help of the Codex and Gemini AI Agents.

closes https://github.com/rsyslog/rsyslog/issues/1255
2025-07-06 14:19:33 +02:00
Rainer Gerhards
afd91282e7
stats: add prometheus format to set of supported output formats 2025-06-04 18:49:32 +02:00
Rainer Gerhards
cd329c3232
CI: user newer OS versions in CI workflow
also bump default development container to Ubuntu 24.04

This commit also contains some nitfixes that were detected
by the newer CI components. If it is just nitfixes, we do not
create separate commits for them.
2024-11-23 11:09:25 +01:00
609cab1620 Fixed wrong type conversion in cstrLen() for debug mode as well
Apply the type conversion correction added by PR
https://github.com/rsyslog/rsyslog/pull/5051 to both definitions
of cstrLen().

Changed types from int to size_t in multiple occurrences
(where cstrLen is used).

closes: https://github.com/rsyslog/rsyslog/issues/5073
2023-01-23 12:37:44 +01:00
Michael Biebl
6569133c75
Typo fixes (#4801)
* typo fix: ambigious -> ambiguous

* typo fix: aquire -> acquire

* typo fix: assgined -> assigned

* typo fix: cancelation -> cancellation

* typo fix: childs -> children

* typo fix: configuraton -> configuration

* typo fix: delemiter -> delimiter

* typo fix: forwardig -> forwarding

* typo fix: initializiation -> initialization

* typo fix: intializing -> initializing

* typo fix: lengh -> length

* typo fix: mesage -> message

* typo fix: occured -> occurred

* typo fix: occurence -> occurrence

* typo fix: paramter -> parameter

* typo fix: remaing -> remaining

* typo fix: resetted -> reset

* typo fix: suppored -> supported

* typo fix: Sytem -> System

* typo fix: uncommited -> uncommitted

* typo fix: depricated -> deprecated

* typo fix: stoping -> stopping

* type fix: allow to -> allow one to
2022-02-17 10:54:12 +01:00
Rainer Gerhards
5fab4e43f4
fix commented out-code
this now handles optional developer debug statements via preprocessor define
2019-03-20 12:38:52 +01:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
3b42d5003b imfile/core bugfix: potential misadressing in string copy routine
This can be exposed via imfile, as follows:

- use a regex to process multiline messages
- configure timeouts
- make sure imfile reads a partial message
- wait so that at least one timeout occurs
- add the message termination sequence

This leads to a misadressing, which may have no obvious effects potentially
up to a segfault.

closes https://github.com/rsyslog/rsyslog/issues/2661
2018-05-16 16:29:27 +02:00
Rainer Gerhards
6a190552d2 core/cstr: stringbuf.c: cstrGetSzStrNoNULL shall not modify buffer
The currently done buffer modification (add of '\0') is bad, especially when
multiple threads access the same string. It is not really an issue that needs
to be urgently fixed, as always the same data is written. However, among others,
it will pollute the thread debugger and as such prevent more elaborate automatted
tests.

closes https://github.com/rsyslog/rsyslog/issues/1993
2017-12-31 18:30:58 +01:00
Rainer Gerhards
68a620fb5c fix potential unsigened integer overflow
should not have a bad impact on all current platforms, as the
result is properly casted. It's still a potential problem spot.

Detecec by clang UBSAN.
2017-12-15 09:35:39 +01:00
Rainer Gerhards
29f9bf6068 core bugfix: undefined behavior due to integer overflow
when searching strings, we may have an (unsigned) interger overflow
which can lead to misadressing.

Detected by clang ubsan.
2017-12-14 18:49:04 +01:00
Rainer Gerhards
a0474fd193 apply some more "const" attributes
... while we are at it ;-)
2017-10-28 11:32:42 +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
Jan Gerhards
779fce20b3 multiple modules: add better error messages when regcomp is failing
see also: https://github.com/rsyslog/rsyslog/issues/1102
2017-06-26 11:03:00 +02:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
Rainer Gerhards
cfacd4c30f code cleanup: fix compiler warnings that newly came up
we got a bunch of new ones under updated Fedora
2016-10-11 14:10:25 +02:00
Rainer Gerhards
b3940cb966 remove excessive "inline" attributes 2016-06-03 12:24:27 +02:00
Rainer Gerhards
5e3b075d53 fix compiler warnings 2016-06-02 12:08:55 +02:00
Rainer Gerhards
8a8675b223 fix compiler warnings 2016-06-02 10:18:05 +02:00
Rainer Gerhards
7989397975 fix bugs introduced today (found by clang static analyzer) 2016-05-19 17:19:29 +02:00
Rainer Gerhards
589ab2b25d cleanup 2016-05-19 12:37:35 +02:00
Rainer Gerhards
1274eced88 stringbuf refactor: combine two almost identical functions 2016-05-19 12:34:26 +02:00
Rainer Gerhards
06530d2694 stringbuf: avoid alloc system calls if not strictly necessary 2016-05-19 12:08:28 +02:00
Rainer Gerhards
16a22f9eff stringbuf refactor: interface change for cstrTrimTrailingWhiteSpace() 2016-05-19 11:09:24 +02:00
Rainer Gerhards
cf9ff7c2b0 stringbuf: remove no longer needed functions
... and some additional minor cleanup while going along
2016-05-19 10:40:36 +02:00
Rainer Gerhards
d20c54a272 stringbuf: a set of minor code and style improvements
e.g. do not call calloc() if malloc() is sufficient, use memcmp()
where possible, ...
2016-05-19 08:55:41 +02:00
Rainer Gerhards
0a1117b43e cleanup 2016-05-19 08:39:50 +02:00
Rainer Gerhards
f097aa2e69 cleanup comments 2016-05-19 08:34:14 +02:00
Rainer Gerhards
f310c51cdf remove unnecessary if
thanks to Magnus Hyllander for telling me
2016-05-18 18:52:10 +02:00
Rainer Gerhards
d3ef5a7bde refactor stringbuf: use only a single string buffer
... both for the internal representation as well as the C-String one.
The module originally tried to support embedded NUL characters, which
over time has prooven to be not necessary. Rsyslog always encodes
NUL into escape sequences.

Also, the dual buffers were used inconsistently, which could lead to
subtle bugs. With the single buffer, this does no longer happen and
we also get some improved performance (should be noticable)
and reduced memory use (a bit).

closes https://github.com/rsyslog/rsyslog/issues/1033
2016-05-18 11:38:55 +02:00
Rainer Gerhards
3df38df810 core/stringbuf: remove NUL character escaping as we do not have NUL chars
see also https://github.com/rsyslog/rsyslog/issues/1033
2016-05-17 13:05:20 +02:00
Janmejay Singh
90019a681a dyn-stats values are now reported (in json, json-es and cee formats) under a key "values" 2016-03-31 00:16:17 +05:30
Rainer Gerhards
5b58aed367 cross-platform: replace format attribute by more standard one 2016-01-27 08:50:29 +01:00
Rainer Gerhards
ed9d9c52bf finally remove no longer needed rsCStrGetSzStr() function 2016-01-12 08:20:31 -05:30
Rainer Gerhards
5087a50b0a refactor: remove or replace deprecated rsCStrGetSzStr() calls 2016-01-12 08:05:39 -05:30
Peter Portante
2470f0f72b Remove use of sizeof(char) and sizeof(uchar)
Remove the use sizeof(char) or sizeof(uchar) in calculations for memory
allocation or string length.  There are no known platforms for which
sizeof(char) or sizeof(uchar) is not 1, and c99 has defined sizeof(char)
to be 1 (section 6.5.3.4 of c99).
2015-12-16 02:18:45 +00:00
Tomas Heinrich
2ce6f44c86 bugfix: prevent a double free
cstrConvSzStrAndDestruct() frees it's first argument but doesn't set
it to NULL as rsCStrDestruct() does. In couple of cases the code using
it assumed it does which could have led to double free.
This commit aligns the prototype of cstrConvSzStrAndDestruct() with
rsCStrDestruct(). The callers were updated for the new behavior and
several potential memleaks were plugged.

Error: USE_AFTER_FREE (CWE-825):
rsyslog-7.4.10/runtime/cfsysline.c:532: freed_arg: "cstrConvSzStrAndDestruct(cstr_t *, uchar **, int)" frees "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:486:2: freed_arg: "free(void *)" frees parameter "pThis".
rsyslog-7.4.10/runtime/cfsysline.c:553: deref_arg: Calling "rsCStrDestruct(cstr_t **)" dereferences freed pointer "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:216:16: var_assign_parm: Assigning: "pThis" = "*ppThis".
rsyslog-7.4.10/runtime/stringbuf.c:218:2: deref_var: Dereferencing "pThis" (which is a copy of "*ppThis").

Error: USE_AFTER_FREE (CWE-825):
rsyslog-7.4.10/outchannel.c:113: freed_arg: "cstrConvSzStrAndDestruct(cstr_t *, uchar **, int)" frees "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:486:2: freed_arg: "free(void *)" frees parameter "pThis".
rsyslog-7.4.10/outchannel.c:118: deref_arg: Calling "rsCStrDestruct(cstr_t **)" dereferences freed pointer "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:216:16: var_assign_parm: Assigning: "pThis" = "*ppThis".
rsyslog-7.4.10/runtime/stringbuf.c:218:2: deref_var: Dereferencing "pThis" (which is a copy of "*ppThis").

Error: USE_AFTER_FREE (CWE-825):
rsyslog-7.4.10/outchannel.c:181: freed_arg: "cstrConvSzStrAndDestruct(cstr_t *, uchar **, int)" frees "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:486:2: freed_arg: "free(void *)" frees parameter "pThis".
rsyslog-7.4.10/outchannel.c:186: deref_arg: Calling "rsCStrDestruct(cstr_t **)" dereferences freed pointer "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:216:16: var_assign_parm: Assigning: "pThis" = "*ppThis".
rsyslog-7.4.10/runtime/stringbuf.c:218:2: deref_var: Dereferencing "pThis" (which is a copy of "*ppThis").

Error: USE_AFTER_FREE (CWE-825):
rsyslog-7.4.10/template.c:480: freed_arg: "cstrConvSzStrAndDestruct(cstr_t *, uchar **, int)" frees "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:486:2: freed_arg: "free(void *)" frees parameter "pThis".
rsyslog-7.4.10/template.c:493: deref_arg: Calling "rsCStrDestruct(cstr_t **)" dereferences freed pointer "pStrB".
rsyslog-7.4.10/runtime/stringbuf.c:216:16: var_assign_parm: Assigning: "pThis" = "*ppThis".
rsyslog-7.4.10/runtime/stringbuf.c:218:2: deref_var: Dereferencing "pThis" (which is a copy of "*ppThis").
2014-07-11 15:19:43 +02:00
Rainer Gerhards
f7ad21626f silence compiler warnings
mostly cosmetic things
2014-03-16 10:52:54 +01:00
Rainer Gerhards
c5fb0111e8 fix compiler warning 2013-10-18 17:52:32 +02:00
Rainer Gerhards
fa8ff7601d slight optimizations: avoid unnecessary writes
but this happens only during config load, so no real gain
2013-10-18 09:38:14 +02:00
Rainer Gerhards
2fe58f67a9 remove obsolete function 2013-10-18 09:13:56 +02:00
Rainer Gerhards
14eb455c50 bugfix: potential misadressing when trimming cstr's 2013-10-18 09:08:05 +02:00
Rainer Gerhards
6b228b1c75 cosmetic: remove compiler warnings 2013-10-18 07:34:45 +02:00
Marius Tomaschewski
4341b2a37d cosmetic: reduce compiler warning
init variable that does not really need to be initialized, as it
is immediately overwritten - but the compiler is not smart enough
to see that
2013-05-14 15:36:50 +02:00
Rainer Gerhards
bcc0f0ae4d bugfix: invalid addressing in string class (recent regression) 2013-05-13 08:23:17 +02:00
Tomas Heinrich
9959f80ee6 Add new string functions that take a printf-style fmt 2013-04-09 17:20:29 +02:00