Florian Forster [Thu, 11 Jan 2024 19:35:30 +0000 (20:35 +0100)]
write_riemann plugin: Terminate `riemann_event_set` arguments with `RIEMANN_EVENT_FIELD_NONE`.
`riemann_event_set` is a variadic function, that means it accepts a variable
number of arguments. That means it needs some way to determine – at runtime
– how many arguments there are. It appears to be doing so by using
`RIEMANN_EVENT_FIELD_NONE` to indicate the last element in the argument
list. Unfortunately I was unable to find the library's documentation and
code and could not verify this.
That means that the argument list passed to `riemann_event_set` was not
always terminated, causing it to read past where it was supposed to and
adding random crap into the message it crafted.
Takuro Ashie [Mon, 26 Oct 2020 02:22:29 +0000 (11:22 +0900)]
lua: Use a global lock to call Lua's API
Since vanilla Lua isn't multi-thread-safe, a global lock should be used
when calling their functions. The previous code causes unstable behavior
especially on loading Lua's C modules with both read & write threads.
Kentaro Hayashi [Mon, 8 Feb 2021 12:26:16 +0000 (21:26 +0900)]
collection3: Fix inappropriate usage of CGI:param
When using collection3 as a CGI, the following error is sent to logs
repeatedly.
FastCGI sent in stderr: "CGI::param called in list context from
/usr/share/doc/collectd-core/examples/collection3/lib/Collectd/Graph/Common.pm
line 529, this can lead to vulnerabilities. See the warning in
"Fetching the value or values of a single named parameter" at
/usr/share/perl5/CGI.pm line 412"
This is caused inappropriate usage of param(), it should be handled as
a scalar or should be treated by multi_param() explicitly.
Florian Forster [Thu, 21 Dec 2023 11:05:45 +0000 (12:05 +0100)]
common: Fix compiler warning in unit test.
Some compilers complained about using a value that depends on the input for the
size argument passed to `strncpy`. They missed that the size of `buf` also
depends on the source argument and therefore this use is fine.
```
CC src/utils/common/common_test.o
../../src/utils/common/common_test.c: In function 'test_parse_values':
../../src/utils/common/common_test.c:316:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
316 | strncpy(buf, cases[i].buffer, buf_sz);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/utils/common/common_test.c:314:21: note: length computed here
314 | size_t buf_sz = strlen(cases[i].buffer) + 1;
| ^~~~~~~~~~~~~~~~~~~~~~~
```
Florian Forster [Tue, 28 Nov 2023 18:31:11 +0000 (19:31 +0100)]
procevent plugin: remove use of a nested flexible array member.
The previous code used an ad-hoc struct to construct or parse a Netlink
message. This relied on allocating a field _after_ the struct with the
flexible array member, which is prohibited by the C standard, leading to
compiler warnings.
Florian Forster [Sat, 25 Nov 2023 13:12:59 +0000 (14:12 +0100)]
SMART plugin: initialize struct passed to `ioctl(2)`.
Valgrind is complaining about a conditional jump based on uninitialized
memory:
```
==66462== Conditional jump or move depends on uninitialised value(s)
==66462== at 0x10C500: smart_read_nvme_intel_disk (in /__w/collectd/collectd/test_plugin_smart)
==66462== by 0x10D366: test_x (in /__w/collectd/collectd/test_plugin_smart)
==66462== by 0x10D638: main (in /__w/collectd/collectd/test_plugin_smart)
```
This may be due to the `struct nvme_additional_smart_log` being
uninitialized when it's being passed to `ioctl(2)`.
This there, this removed an unnecessary level of indentation.
Florian Forster [Sat, 25 Nov 2023 12:51:57 +0000 (13:51 +0100)]
Netlink plugin: complete initialize structs used for testing.
Valgrind complains about a conditional jump based on uninitialized
memory:
```
==66438== Conditional jump or move depends on uninitialised value(s)
==66438== at 0x10CA06: vf_info_submit (in /__w/collectd/collectd/test_plugin_netlink)
==66438== by 0x1110F2: test_vf_submit_test (in /__w/collectd/collectd/test_plugin_netlink)
==66438== by 0x112EAC: main (in /__w/collectd/collectd/test_plugin_netlink)
```
This is likely caused by the `vf_stats_t` being only partially
initialized. Using a struct initializer is not only cleaner, it also
ensures the remainder of the struct is initialized to zero.
Florian Forster [Fri, 24 Nov 2023 11:04:25 +0000 (12:04 +0100)]
Build workflow: remove old distros.
This removes old and unsupported Linux distros:
* Ubuntu 16 ("Xenial", support ended April 2021)
* Ubuntu 18 ("Bionic Beaver", support ended June 2023)
* Enterprise Linux 7 (technically still supported, but nine years old
at this point)
* Fedora 34 (support ended June 2022)
* Fedora 35 (support ended December 2022)
Fedora 36 is also unsupported. We will keep the builder until we have
never versions of Fedora available (or at least Rawhide builds again).
Florian Forster [Fri, 24 Nov 2023 13:14:05 +0000 (14:14 +0100)]
AMQP plugin: prefer the `rabbitmq-c/amqp.h` header if available.
At some point, RabbitMQ has moved their headers to the `rabbitmq-c/`
subdirectory. The old locations still exist but throw an error, saying
the old headers are "deprecated".
This adds appropriate checks for the new headers to the configure script
and uses those if present.
To simplify both the configure script and plugin, support for ancient
versions of the library is removed. This affects versions that don't
have the `amqp_tcp_socket_new()` function yet.
Florian Forster [Fri, 24 Nov 2023 08:15:04 +0000 (09:15 +0100)]
Write MongoDB plugin: fix format trunction errors.
When a `size_t` is a 64bit integer, the 16 byte buffer could potentially
overflow. Fix this by using a larger buffer and also collectd's own
`ssnprintf()` function which guarantees to result in a null terminated
string.
```
In function 'wm_create_bson',
inlined from 'wm_write' at src/write_mongodb.c:229:17:
src/write_mongodb.c:99:32: error: '%zu' directive output may be truncated writing between 1 and 20 bytes into a region of size 16 [-Werror=format-truncation=]
99 | snprintf(key, sizeof(key), "%" PRIsz, i);
| ^~~
src/write_mongodb.c: In function 'wm_write':
src/write_mongodb.c:99:33: note: format string is defined here
99 | snprintf(key, sizeof(key), "%" PRIsz, i);
```
Florian Forster [Fri, 24 Nov 2023 07:28:06 +0000 (08:28 +0100)]
curl_stats: fix compatibility with new versions of cURL.
Use integer based keys for metrics if available.
cURL ≥ 7.55.0 provides additional keys that allow getting certain
metrics as integers rather than doubles, e.g. content length. In some
newer versions of cURL, the original keys (using doubles) are marked as
deprecated.
ChangeLog: cURL, cURL-JSON, cURL-XML, Write HTTP plugins: fix compatibility with new versions of cURL.
Wolf480pl [Tue, 21 Nov 2023 10:53:59 +0000 (11:53 +0100)]
write_prometheus: don't use AI_ADDRCONFIG for resolving bind address
Fixes #4150
write_prometheus uses getaddrinfo to resolve the bind address.
The AI_ADDRCONFIG flag causes getaddrinfo to refuse to resolve
0.0.0.0 when the system has no non-loopback IPv4 addresses configured
and refuse to resolve :: when the system has no non-loopback IPv6 configured.
We want binding to a wildcard address (0.0.0.0 or ::) to always work,
even if the network is down.
To achieve that, don't pass the AI_ADDRCONFIG flag
when resolving a bind address.