Commit graph

273 commits

Author SHA1 Message Date
Alvar
bccb38dc9d
check_icmp: Populate progname before np_extra_opts call (#2226)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Spellcheck / codespell (push) Has been cancelled
Tests / Running unit and integrationt tests (push) Has been cancelled
Tests / Running rpm build test on almalinux:9 (push) Has been cancelled
Tests / Running rpm build test on fedora:latest (push) Has been cancelled
Tests / Running rpm build test on rockylinux:8 (push) Has been cancelled
Tests Debian:Testing and Fedora:Rawhide / Running unit and integrationt tests (push) Has been cancelled
Tests Debian:Testing and Fedora:Rawhide / Running rpm build test on fedora:rawhide (push) Has been cancelled
Within np_extra_opts, the ini parser expects a valid progname as the
default section to select a configuration section in the ini file.
However, within the check_icmp codebase, the progname is being populated
directly after the np_extra_opts call, being a null pointer before.

$ ./check_icmp --extra-opts=@foo.ini
Segmentation fault (core dumped)

> #0  strlen () at /usr/src/lib/libc/arch/amd64/string/strlen.S:125
> #1  0x000003989615d032 in _libc_strdup (str=Variable "str" is not available.) at /usr/src/lib/libc/string/strdup.c:44
> #2  0x000003966f751b74 in np_get_defaults (locator=0x73ede1e538ea "@foo.ini", default_section=0x0) at parse_ini.c:91
> #3  0x000003966f7518ce in np_extra_opts (argc=0x73ede1e5369c, argv=0x73ede1e53728, plugin_name=0x0) at extra_opts.c:98
> #4  0x000003966f74165a in main (argc=1, argv=0x0) at check_icmp.c:832

The progname variable is set within the process_arguments function,
requiring the already enriched arguments from np_extra_opts. Thus, I
moved the progname detection out of this function, directly before the
np_extra_opts call. This pattern does already exists in check_tcp.

I briefly looked for similar issues in other plugins, but found none.
2026-01-19 01:00:00 +01:00
Lorenz Kästle
b58e244cc7
check_icmp: prevent segfault on OpenBSD (#2224)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
* check_icmp: prevent segfault on OpenBSD

This commit adds a sanity check for sockets in
check_icmp.
Previously FD_ISSET segfaulted when a socket value was
-1 (on OpenBSD). The changes here add an explicit
check whether the socket is -1 (and therefore not
set).

---------

Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
2026-01-16 02:42:01 +01:00
Lorenz Kästle
f15029d856 check_icmp: fix some compiler warnings (and maybe bugs) 2026-01-09 13:41:28 +01:00
Alvar Penning
b27bf07ebf
plugins-root/check_icmp: Fix build for SIOCGIFADDR
The refactoring in eafee9c3f9 missed the
part within "#if defined(SIOCGIFADDR)" in get_ip_address.
2025-12-11 21:05:49 +01:00
Alvar Penning
cbddc7dbb4
plugins-root/check_icmp: Import sys/ioctl.h
The ioctl(2) call within "#if defined(SIOCGIFADDR)" requires the include.
2025-12-11 21:05:49 +01:00
Lorenz Kästle
811da10fda More refactoring 2025-09-15 15:49:26 +02:00
Lorenz Kästle
802e46f8ea Run clang-format again 2025-09-15 12:59:37 +02:00
Lorenz Kästle
9f776105d4 Reapply "check_dhcp: reduce number of tests for weird reasons"
This reverts commit 612d261cbf.
2025-06-23 13:21:25 +02:00
Lorenz Kästle
612d261cbf Revert "check_dhcp: reduce number of tests for weird reasons"
This reverts commit 52338c3423.
2025-06-23 13:02:52 +02:00
Lorenz Kästle
528d2015d0 Add check_dhcp related files to Makefile 2025-06-23 13:02:41 +02:00
Lorenz Kästle
52338c3423 check_dhcp: reduce number of tests for weird reasons 2025-06-23 12:33:28 +02:00
Lorenz Kästle
bf0b389381 Adapt tests 2025-06-23 12:09:58 +02:00
Lorenz Kästle
d3f22c96bb check_dhcp: little fix to output 2025-06-23 12:09:58 +02:00
Lorenz Kästle
0453d6d1e2 Refactor check_dhcp 2025-06-23 12:09:58 +02:00
Lorenz Kästle
a0d3493f9d check_dhcp: clang-format 2025-06-23 12:09:58 +02:00
Lorenz Kästle
bd55d9cd2d check_icmp: Add missing line ending in help 2025-06-23 11:46:45 +02:00
Lorenz Kästle
8626d22fc5 check_icmp: trigger help before anything important 2025-06-23 11:44:46 +02:00
Lorenz Kästle
6ac0580a10 check_icmp: Add comment to config 2025-06-23 11:42:25 +02:00
Lorenz Kästle
622d7f4c89 check_icmp: add long options to help 2025-06-23 11:41:56 +02:00
Lorenz Kästle
bf67d5cb53 check_icmp: remove dead comment 2025-06-23 11:41:41 +02:00
Lorenz Kästle
771ccfa526 check_icmp: remove unnecessary variable 2025-06-23 11:41:24 +02:00
Lorenz Kästle
7e9519e0ad check_icmp: correct output strings 2025-06-23 10:59:21 +02:00
Lorenz Kästle
b08bafc45c check_icmp: remove paket_interval, was never used anyway 2025-06-23 10:52:56 +02:00
Lorenz Kästle
27d30c3df0 Fix typo 2025-06-23 10:34:12 +02:00
Lorenz Kästle
efba4f7654 check_icmp: cleanup some leftover comments 2025-06-23 10:32:24 +02:00
Lorenz Kästle
cd20cc0632 check_icmp: add long options, add output format option
This commit switches check_icmp from getopt to getopt_long
to provide long options too and (most importantly) homogenize
option parsing between the different plugins.
2025-06-23 10:17:28 +02:00
Lorenz Kästle
8ae415ee4c Improve check_icmp help output 2025-06-23 10:16:42 +02:00
Lorenz Kästle
d2735eecd4 Fix number of tests 2025-06-20 10:53:46 +02:00
Lorenz Kästle
6bc2e75199 Fix test with weird arguments 2025-06-20 10:28:45 +02:00
Lorenz Kästle
2bea8e9522 check_icmp: Remove signal handling and timeouts
The timeout option was redundant in that the runtime
of check_icmp was always limited by the input parameters
and therefore timeout gets removed with this commit to
avoid that confusion.

The rest of the signal handlings was removed too, since
the added complexity does not provide sufficient returns.
If check_icmp gets a signal, it now dies like most other
programs instead of trying to save some things and return a
(arguably wrong) result.
2025-06-20 10:04:34 +02:00
Lorenz Kästle
20e938bb54 Override state with min_hosts_alive 2025-06-19 01:15:37 +02:00
Lorenz Kästle
ca954e4f76 Reintroduce min_hosts_alive 2025-06-19 00:55:41 +02:00
Lorenz Kästle
43ae5fbe2d Fix possible multiplication overflow? 2025-06-17 15:44:35 +02:00
Lorenz Kästle
f680cd7b88 Improve error detection for threshold parsers 2025-06-17 15:19:30 +02:00
Lorenz Kästle
0f8690c19b Remove check_icmp text regex tests 2025-06-09 12:42:17 +02:00
Lorenz Kästle
906e895c72 Format specifier fixes 2025-05-18 19:19:07 +02:00
Lorenz Kästle
738d58714d some more fixes 2025-05-18 19:11:14 +02:00
Lorenz Kästle
3b76fdc840 Fix typos 2025-05-18 18:48:49 +02:00
Lorenz Kästle
d92bbaef83 Some more fixes 2025-05-18 18:46:30 +02:00
Lorenz Kästle
b5de682309 WIP - check_icmp refactor 8 2025-05-18 18:10:25 +02:00
Lorenz Kästle
8f08e7ab3e WIP - check_icmp refactor 7 2025-05-18 14:44:31 +02:00
Lorenz Kästle
fbcd11acb7 Clang-format 2025-05-18 00:20:36 +02:00
Lorenz Kästle
a01d522c4c WIP - check_icmp refactor 6 2025-05-17 11:49:06 +02:00
Lorenz Kästle
322cd6f829 Lib: Add perfdata for char and unsigned char 2025-05-17 11:26:27 +02:00
Lorenz Kästle
6b86583e0d WIP - check_icmp refactor 5 2025-05-16 12:46:56 +02:00
Lorenz Kästle
9ebde5eb09 WIP - check_icmp refactor 4 2025-05-06 00:01:42 +02:00
Lorenz Kästle
5fd8191a50 WIP - check_icmp refactor 3 2025-05-05 22:52:56 +02:00
Lorenz Kästle
5a6adcb7db WIP - check_icmp refactor 2 2025-05-04 01:42:52 +02:00
Lorenz Kästle
eafee9c3f9 WIP: check_icmp refactor 2025-04-28 22:01:01 +02:00
Lorenz Kästle
f62f182653 check_icmp: localise variables 2025-04-02 01:04:25 +02:00