Commit graph

2618 commits

Author SHA1 Message Date
Richard Laager
661ecff45c check_ssh: Fix buffer overflow
A buffer overflow was occurring when the server responded with:
Exceeded MaxStartups\r\n

glibc would then abort() with the following output:
*** buffer overflow detected ***: terminated

It was the memset() that was overflowing the buffer.  But the memmove()
needed fixing too.

First off, there was an off-by-one error in both the memmove() and
memset().  byte_offset was already set to the start of the data _past_
the newline (i.e. len + 1).  For the memmove(), incrementing that by 1
again lost the first character of the additional output.  For the
memset(), this causes a buffer overflow.

Second, the memset() has multiple issues.  The comment claims that it
was NULing (sic "null") the "rest".  However, it has no idea how long
the "rest" is, at this point.  It was NULing BUFF_SZ - byte_offset + 1.
After fixing the off-by-one / buffer overflow, it would be NULing
BUFF_SZ - byte_offset.  But that doesn't make any sense.  The length of
the first line has no relation to the length of the second line.

For a quick-and-dirty test, add something like this just inside the
while loop:
memcpy(output,
  "Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0",
  sizeof("Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0"));

And, after the memmove(), add:
  printf("output='%s'\n", output);

If you fix the memset() buffer overflow, it will output:
output='ext blah1 blah2 blah3 '

As you can see, the first character is lost.

If you then fix the memmove(), it will output:
output='next blah1 blah2 blah3'

Note that this is still losing the "blah4".

After moving the memset() after byte_offset is set to the new strlen()
of output, then it works correctly:
output='next blah1 blah2 blah3 blah4'

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2025-07-11 18:43:59 -05:00
Lorenz Kästle
b191a8a055 check_load: fix tests 2025-07-06 23:16:34 +02:00
Lorenz Kästle
92c7b91002 Merge branch 'master' into refactor/check_load 2025-07-06 22:49:04 +02:00
Lorenz Kästle
351b104894 check_load some number type fixes 2025-07-06 22:46:41 +02:00
Lorenz Kästle
b002a6870b check_load: Add top x functionality to output 2025-07-06 21:58:55 +02:00
Lorenz Kästle
4ef8af0d9a check_load: remove useless code and do some formatting 2025-07-06 21:46:54 +02:00
Lorenz Kästle
882ef5015f Merge branch 'master' into refactor/check_procs 2025-06-28 09:53:59 +02:00
Lorenz Kästle
b8580c18e3
Merge pull request #2125 from RincewindsHat/refactor/check_icmp
Refactor check_icmp:

 - Far less global variables
 - Proper IPv6/legacy IP dual stack functionality (allowed mixed v4/v6 hosts)
 - Improved readability/understandability
 - General cleanup
2025-06-20 11:29:07 +02:00
Lorenz Kästle
a669b2531d Remove options if fping version is too low and die directly 2025-06-12 13:33:50 +02:00
Lorenz Kästle
19f409ac55 Remove unnecessary newline 2025-06-12 13:26:55 +02:00
Lorenz Kästle
f2c6ce08e3 check_fping: small style improvement 2025-06-12 11:53:06 +02:00
Lorenz Kästle
7247fc656a Implement new fping options for fping 5.2 and 5.3
fping 5.2 and 5.3 add some new useful command line options
which this commit add to check_fping.

These are:

 * --fwmark - sets a firewall mark in the packages to make them
   identifiable (fping 5.2)
 * --icmp-timestamp - fping uses ICMP timestamp instead of ICMP
   Echo (fping 5.2)
 * --check-source - fping discards replies which originate not from
   the target address (fping 5.2)

The fping release notes describe theses options ( https://github.com/schweikert/fping/releases )
in a little bit more detail.
Currently the help display for those options is only shown
when fping was available in the appropriate version during
compilation.
2025-06-12 11:13:59 +02:00
Lorenz Kästle
dd93b1403a utils: Make fmt function for compiler 2025-05-18 19:19:23 +02:00
William
1fb9300a2f Remove un-needed flags 2025-05-07 13:17:47 +10:00
William
58a3424511 Improve logic 2025-05-07 13:15:51 +10:00
William
a1472be883 Harden check with unspec 2025-05-07 13:15:51 +10:00
William
4acba2b3ec Improve handling of -4/-6
If fping is used with a target that has dual stack v4/v6, then due to
the logic during command construction, ipv4 will never be checked as v6
is preferred by fping.

This explicitly flags -4/-6 when it is requested by the user.
2025-05-07 13:15:51 +10:00
Jan Wagner
14169fe5a1 check_http: Adding deprecation text 2025-04-21 10:55:23 +02:00
Lorenz Kästle
4924bc877f
Merge pull request #2113 from RincewindsHat/refactor/check_disk
Refactor/check disk
2025-03-31 23:58:02 +02:00
Lorenz Kästle
13c9de8c77 Try fixing some tests 2025-03-31 23:40:22 +02:00
Lorenz Kästle
24a50b9421 check_disk: decrease precision to avoid false negatives with small measurement changes 2025-03-31 22:18:19 +02:00
Lorenz Kästle
1b0085c2e7 Fixes problems after a4cf2e79f7 2025-03-31 00:46:10 +02:00
Lorenz Kästle
d6d394fb0e Fix some typos with units 2025-03-31 00:10:56 +02:00
Lorenz Kästle
d1d6ba6706 Add debugging to tests for CI 2025-03-30 23:42:50 +02:00
Lorenz Kästle
a4cf2e79f7 Remove cool, comfy c23 functionality for some dirty old hacks 2025-03-30 23:30:51 +02:00
Lorenz Kästle
c4fd34ed79 Codespell fixes 2025-03-30 22:46:09 +02:00
Lorenz Kästle
76971dea75 Address check_disk changes in tests 2025-03-30 22:38:12 +02:00
Lorenz Kästle
908aed4e6f Refactor check_disk and library functions 2025-03-30 22:37:48 +02:00
Lorenz Kästle
a0710dbd72 check_disk: Remove unnecessary NULL checks 2025-03-18 16:26:14 +01:00
Lorenz Kästle
42531fa92a Refactor test_check_disk.c 2025-03-18 16:23:33 +01:00
Lorenz Kästle
75cf0d3072 Remove some unused code 2025-03-18 16:23:06 +01:00
Lorenz Kästle
59e0a258f9 Migrate disk tests from lib, tool 2025-03-18 15:57:44 +01:00
Lorenz Kästle
29d946b9b5 Refactor check_disk, no more global variables 2025-03-18 14:37:49 +01:00
Lorenz Kästle
8ccff07bed refactor check_disk.d code a bit 2025-03-18 14:37:02 +01:00
Lorenz Kästle
285db2a9fa Move disk specific stuff from lib to plugin specific directory 2025-03-18 14:36:20 +01:00
Lorenz Kästle
096afc90a7 check_disk: reset single file system result in between checks 2025-03-17 20:37:28 +01:00
Lorenz Kästle
7b53cbbd26 check_disk: Little fixes and improvements 2025-03-17 20:21:58 +01:00
Andre Klärner
ef3045b97e change error message for missing certificate
The old error message is quite similar to the openssl `failed to retrieve issuer certificate` and can mislead users to troubleshooting certificate stores.

The new message should be distinct enough to make it clear to users that this is not a problem raised by the underlying SSL implementation, but a problem inside monitoring-plugins.
2025-03-17 20:17:28 +01:00
Lorenz Kästle
4fb7fb05b6 check_disk: General refactoring 2025-03-17 19:36:11 +01:00
Lorenz Kästle
969f40c2a0 check_disk: boolean type and linter fixes 2025-03-17 17:44:28 +01:00
Lorenz Kästle
d24316a6b4 check_disk: clang-format 2025-03-17 17:40:29 +01:00
Lorenz Kästle
d99cd375fc
Merge pull request #2100 from RincewindsHat/remove/check_nwstat
Remove check_nwstat
2025-03-17 13:56:55 +01:00
Lorenz Kästle
e04d2ec8c6 check_swap: Fixes on NetBSD 2025-03-17 12:58:12 +01:00
Lorenz Kästle
abc87a3d6d check_ping: fix some variables forgotten during refactoring 2025-03-17 12:57:21 +01:00
Lorenz Kästle
7a5fa0cc5c check_ide_smart: use the more common C90 fixed width integers 2025-03-17 12:56:42 +01:00
Lorenz Kästle
5eaeadbb3a check_load: Actually allow output format configuring 2025-03-14 00:04:02 +01:00
Lorenz Kästle
fedff97c96 improved includes and some comments 2025-03-13 23:51:51 +01:00
Lorenz Kästle
205b97b3e2 check_load: Remove output formatting test and adapt others 2025-03-13 23:48:33 +01:00
Lorenz Kästle
08a475a14f Refactor check_load + new ouput 2025-03-13 23:41:12 +01:00
Lorenz Kästle
f2900e0ccf check_load: clang-format 2025-03-13 15:36:36 +01:00