40 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
Dominik Andreas Schorpp
5c4f0ffe74 outchannel: remove unnecessary type cast
According to the manpage the input for isspace must be of type unsigend char.
Remove all unnecessary type cast to achieve this.
2023-03-08 17:56:06 +01:00
alakatos
66bcd91196 Clarify meaning of loadConf and RunConf 2021-12-15 10:26:52 +01:00
alakatos
4fc5ed645a Deallocate outchannel resources in rsconf destructor 2021-11-30 18:15:33 +01:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
PascalWithopf
c83e3ed216 correct codestyle in rsyslog part 2 2018-08-01 16:11:33 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
PascalWithopf
29c9fb1f9a codestyle: reduce line length to 120
lines are still checked for a length of 125 because
these are just some of the lines
2017-12-21 17:09:32 +01:00
PascalWithopf
79de51e4fc codestyle: reduce max line length to 125 2017-12-20 16:16:57 +01:00
Rainer Gerhards
448f16495c remove "inline" attribute from excessivly long functions 2016-10-26 11:50:15 +02:00
Rainer Gerhards
f8738727f9 change cstrFinalize() interface
the function can no longer fail and it is not expected that this
will ever happen again in the future. So we remove the return value,
giving a small speedup to the code.
2016-05-19 10:49:37 +02:00
Peter Portante
84f5608157 Fix upper and mixed case variable references
We could not reference mixed or upper case variables properly prior to
this change, as they were always lowercased before references were
pulled.

The new "option.casesensitive" for templates allows folks to turn on
variable name reference case sensitivity on a template by template
basis.
2015-12-19 16:17:11 +00:00
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
ac9afc4149 Merge branch 'v5-stable' into master
Conflicts:
	ChangeLog
	action.h
	configure.ac
	doc/manual.html
	plugins/immark/immark.c
	plugins/impstats/impstats.c
	plugins/imptcp/imptcp.c
	plugins/imtcp/imtcp.c
	runtime/cfsysline.c
	runtime/cfsysline.h
	runtime/conf.c
	runtime/ctok.c
	runtime/ctok.h
	runtime/ctok_token.c
	runtime/ctok_token.h
	runtime/dnscache.h
	runtime/expr.c
	runtime/expr.h
	runtime/rule.c
	runtime/rule.h
	runtime/ruleset.h
	runtime/sysvar.c
	runtime/vm.h
	runtime/vmop.c
	runtime/vmop.h
	runtime/vmprg.c
	runtime/vmprg.h
	runtime/vmstk.c
	runtime/vmstk.h
	tools/omusrmsg.c
2012-01-18 14:08:24 +01:00
Rainer Gerhards
0871d0a077 Merge branch 'v4-stable' into v5-stable
Conflicts:
	plugins/imfile/imfile.c
	plugins/omtesting/omtesting.c
	tcpsrv.c
	threads.c
2012-01-14 18:32:40 +01:00
Rainer Gerhards
0216053099 relicense parts under ASL 2.0
after carful check for copyright holder
2012-01-11 18:30:33 +01:00
Rainer Gerhards
19c8bed08d step: outchannel list integrated into main config object 2011-04-26 17:30:59 +02:00
Rainer Gerhards
e04e1b5002 enhanced test environment (including testbench)
support for enhancing probability of memory addressing failure by
using non-NULL default value for malloced memory (optional, only if
requested by configure option). This helps to track down some
otherwise undetected issues within the testbench and is expected
to be very useful in the future.
2009-10-22 11:33:38 +02:00
Rainer Gerhards
464dcf2339 some more stringbuffer optimization 2009-06-25 18:44:48 +02:00
Rainer Gerhards
f7579e68a6 done various optimizations to the stringbuf and its users 2009-06-16 11:36:05 +02:00
Rainer Gerhards
d9b0c77d3e some more cleanup
reduced dependencies, moved non-runtime files to its own directory except
for some whom's status is unclear
2008-04-16 15:27:53 +02:00
Rainer Gerhards
890f782323 some cleanup 2008-04-11 17:33:13 +02:00
Rainer Gerhards
80e69562be did some portability changes to make rsyslog compile on HP UX 2008-03-05 07:01:35 +00:00
Rainer Gerhards
013073f1a6 changed rsCStrObj name to cstr_t, which is more inline with the rest of
rsyslog (now) and also much easier to type
2008-02-21 07:00:29 +00:00
Rainer Gerhards
cd2b24dfc4 - added doc on how expressions will work
- cleaned up the stringbuf Construct interface
- did some cleanup on stringbuf calls - we now have much better interfaces
    and macros
2008-02-19 10:30:42 +00:00
Rainer Gerhards
e5a6c66766 removed some no-longer-needed code (thanks Michael Biebl for the help) 2008-01-05 16:36:53 +00:00
Rainer Gerhards
004229dda6 changed license to GPLv3 (for what is to become rsyslog v3) 2007-12-14 11:21:57 +00:00
Rainer Gerhards
82aeadce54 - changed part of the CStr interface so that better error tracking is
provided and the calling sequence is more intuitive (there were invalid
    calls based on a too-weired interface)
- (hopefully) fixed some remaining bugs rooted in wrong use of the CStr
    class. These could lead to program abort.
2007-09-05 15:59:47 +00:00
Michael Meckelein
f2511d3c61 changed rsyslog.h include order to solve debian sid zlib inlcude issue 2007-08-08 10:49:38 +00:00
Rainer Gerhards
fed254a29f changed function name dprintf() to dbgprintf() as it conflicts with the
clib
2007-08-08 08:20:06 +00:00
Rainer Gerhards
4a963e5f1f code cleanup (removed compiler warnings 2007-07-18 15:16:15 +00:00
Rainer Gerhards
3f08e1f726 moving towards autotools build system - config.h include forgotten & now
fixed
2007-07-11 10:53:58 +00:00
Rainer Gerhards
456c701f8c some more unsigned char conversions... 2007-07-04 09:41:42 +00:00
Rainer Gerhards
489a51be23 applied patch from Bartosz Kuzma to compile cleanly under NetBSD; changed a
number of char to unsigned char
2007-07-03 16:32:27 +00:00
Rainer Gerhards
caf76db7c0 prepared for new parse object; now removed allmost all liblogging borrowed
code
2005-09-15 10:33:47 +00:00
Rainer Gerhards
9a39532d95 initial implementation of the counted string class completed (but so far
only a very feature-less class). code compiles again.
2005-09-09 12:52:23 +00:00
Rainer Gerhards
f2fc13115a fixed some issues on FreeBSD 2005-06-28 12:41:03 +00:00
Rainer Gerhards
3539db6ef7 quick (&dirty) fix four outchannel.h under bsd - requires further fixing on
all platforms
2005-06-27 16:21:48 +00:00
Rainer Gerhards
b14349ab99 outchannel.c for 0.9.0 forgotten 2005-06-27 16:11:35 +00:00