mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-02-18 18:17:50 -05:00
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
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>
This commit is contained in:
parent
6716001002
commit
b58e244cc7
1 changed files with 5 additions and 2 deletions
|
|
@ -1470,10 +1470,13 @@ static recvfrom_wto_wrapper recvfrom_wto(const check_icmp_socket_set sockset, vo
|
|||
};
|
||||
|
||||
ssize_t ret;
|
||||
if (FD_ISSET(sockset.socket4, &read_fds)) {
|
||||
|
||||
// Test explicitly whether sockets are in use
|
||||
// this is necessary at least on OpenBSD where FD_ISSET will segfault otherwise
|
||||
if ((sockset.socket4 != -1) && FD_ISSET(sockset.socket4, &read_fds)) {
|
||||
ret = recvmsg(sockset.socket4, &hdr, 0);
|
||||
result.recv_proto = AF_INET;
|
||||
} else if (FD_ISSET(sockset.socket6, &read_fds)) {
|
||||
} else if ((sockset.socket6 != -1) && FD_ISSET(sockset.socket6, &read_fds)) {
|
||||
ret = recvmsg(sockset.socket6, &hdr, 0);
|
||||
result.recv_proto = AF_INET6;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue