Merge branch 'master' into compiler_warning_part_3

This commit is contained in:
waja 2023-06-28 16:39:09 +02:00 committed by GitHub
commit 103217831e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 5431 additions and 4064 deletions

View file

@ -1,3 +1,4 @@
---
version: 2
updates:
- package-ecosystem: github-actions

View file

@ -5,13 +5,18 @@ set -e
export DEBIAN_FRONTEND=noninteractive
sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
apt-get update
apt-get -y install software-properties-common
if [ $(lsb_release -is) = "Debian" ]; then
apt-add-repository non-free
apt-get update
source /etc/os-release
if [ ${ID} = "debian" ]; then
if [ -f /etc/apt/sources.list.d/debian.sources ]; then
sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
else
apt-get update
apt-get -y install software-properties-common
apt-add-repository non-free
fi
fi
apt-get update
apt-get -y install perl \
autotools-dev \
libdbi-dev \
@ -83,7 +88,7 @@ cp tools/squid.conf /etc/squid/squid.conf
service squid start
# mariadb
service mariadb start
service mariadb start || service mysql start
mysql -e "create database IF NOT EXISTS test;" -uroot
# ldap

View file

@ -1,3 +1,4 @@
---
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
@ -13,10 +14,10 @@ name: "CodeQL"
on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '15 18 * * 0'
@ -32,41 +33,41 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
language: ['cpp']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Install packages
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
- name: Install packages
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
- name: Configure build
run: |
./tools/setup
./configure --enable-libtap
- name: Configure build
run: |
./tools/setup
./configure --enable-libtap
- name: Build
run: |
make
- name: Build
run: |
make
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View file

@ -1,9 +1,11 @@
---
name: Test
on:
push:
branches:
- '*'
# Run test for any PRs
pull_request:
jobs:

1
.gitignore vendored
View file

@ -246,6 +246,7 @@ NP-VERSION-FILE
/plugins-scripts/check_ircd
/plugins-scripts/check_log
/plugins-scripts/check_mailq
/plugins-scripts/check_mssql
/plugins-scripts/check_ntp
/plugins-scripts/check_oracle
/plugins-scripts/check_rpc

View file

@ -24,7 +24,7 @@
*
*****************************************************************************/
#include "common.h"
#include "../plugins/common.h"
#include <stdarg.h>
#include "utils_base.h"
#include <ctype.h>
@ -319,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
while (1) {
/* Strip any leading space */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (strncmp(name, varlist, strlen(name)) == 0) {
varlist += strlen(name);
/* strip trailing spaces */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (varlist[0] == '=') {
/* We matched the key, go past the = sign */
varlist++;
/* strip leading spaces */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (tmp = index(varlist, sep)) {
/* Value is delimited by a comma */

View file

@ -147,24 +147,25 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
/* set best match if path name exactly matches a mounted device name */
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
if (strcmp(me->me_devname, d->name)==0)
best_match = me;
if (strcmp(me->me_devname, d->name)==0) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
best_match = me;
}
}
}
/* set best match by directory name if no match was found by devname */
if (! best_match) {
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
size_t len = strlen (me->me_mountdir);
if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
(len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
|| (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
{
best_match = me;
best_match_len = len;
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
best_match = me;
best_match_len = len;
}
}
}
}

View file

@ -470,10 +470,6 @@ int send_dhcp_discover(int sock){
packet_xid=random();
discover_packet.xid=htonl(packet_xid);
/**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/
/* downright bizzarre... */
ntohl(discover_packet.xid);
/*discover_packet.secs=htons(65535);*/
discover_packet.secs=0xFF;

View file

@ -105,11 +105,11 @@ while test -n "$1"; do
case "$1" in
-h | --help)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-V | --version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-F | --filename)
logfile=$2

View file

@ -86,20 +86,20 @@ esac
# Information options
case "$cmd" in
--help)
print_help
exit "$STATE_OK"
print_help
exit "$STATE_UNKNOWN"
;;
-h)
print_help
exit "$STATE_OK"
print_help
exit "$STATE_UNKNOWN"
;;
--version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_UNKNOWN"
;;
-V)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_UNKNOWN"
;;
esac

View file

@ -26,19 +26,19 @@ print_help() {
case "$1" in
--help)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-h)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
--version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-V)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
*)
sensordata=$(sensors 2>&1)

View file

@ -2217,11 +2217,10 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
if( strchr( p, '.' ) != NULL ) {
/* HTTP 1.x case */
char *ppp;
ppp = strtok( p, "." );
strtok( p, "." );
status_line->http_major = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( first_line_buf ); return -1; }
ppp = strtok( NULL, " " );
strtok( NULL, " " );
status_line->http_minor = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( first_line_buf ); return -1; }
p += 4; /* 1.x SP */

View file

@ -626,21 +626,36 @@ process_arguments (int argc, char **argv)
if (! strcasecmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
} else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
} else if (!strcmp(optarg, "KiB")) {
mult = (uintmax_t)1024;
units = strdup ("kiB");
} else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
units = strdup ("KiB");
} else if (! strcmp (optarg, "kB")) {
mult = (uintmax_t)1000;
units = strdup ("kB");
} else if (!strcmp(optarg, "MiB")) {
mult = (uintmax_t)1024 * 1024;
units = strdup ("MiB");
} else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
} else if (! strcmp (optarg, "MB")) {
mult = (uintmax_t)1000 * 1000;
units = strdup ("MB");
} else if (!strcmp(optarg, "GiB")) {
mult = (uintmax_t)1024 * 1024 * 1024;
units = strdup ("GiB");
} else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
} else if (! strcmp (optarg, "GB")){
mult = (uintmax_t)1000 * 1000 * 1000;
units = strdup ("GB");
} else if (!strcmp(optarg, "TiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
units = strdup ("TiB");
} else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
} else if (! strcmp (optarg, "TB")) {
mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
units = strdup ("TB");
} else if (!strcmp(optarg, "PiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
units = strdup ("PiB");
} else if (! strcmp (optarg, "PB")){
mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
units = strdup ("PB");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}

View file

@ -1391,7 +1391,6 @@ char *unchunk_content(const char *content) {
// https://en.wikipedia.org/wiki/Chunked_transfer_encoding
// https://www.rfc-editor.org/rfc/rfc7230#section-4.1
char *result = NULL;
size_t content_length = strlen(content);
char *start_of_chunk;
char* end_of_chunk;
long size_of_chunk;

View file

@ -138,7 +138,10 @@ main (int argc, char **argv)
mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
/* establish a connection to the server and error checking */
if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR)
/* Depending on internally-selected auth plugin MySQL might return */
/* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */
/* Semantically these errors are the same. */
if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR))
{
printf("MySQL OK - Version: %s (protocol %d)\n",
mysql_get_server_info(&mysql),
@ -551,7 +554,7 @@ print_help (void)
printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds"));
printf (" %s\n", _("behind master"));
printf (" %s\n", "-l, --ssl");
printf (" %s\n", _("Use ssl encryptation"));
printf (" %s\n", _("Use ssl encryption"));
printf (" %s\n", "-C, --ca-cert=STRING");
printf (" %s\n", _("Path to CA signing the cert"));
printf (" %s\n", "-a, --cert=STRING");

View file

@ -341,7 +341,7 @@ int main(int argc, char **argv){
2) If the counter you're going to measure is percent-based, the code will detect
the percent sign in its name and will attribute minimum (0%) and maximum (100%)
values automagically, as well the ¨%" sign to graph units.
values automagically, as well the "%" sign to graph units.
3) OTOH, if the counter is "absolute", you'll have to provide the following
the counter unit - that is, the dimensions of the counter you're getting. Examples:

View file

@ -517,7 +517,10 @@ print_help (void)
printf (" %s\n", _("connecting to the server. The result from the query has to be numeric."));
printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result "));
printf (" %s\n", _("of the last command is taken into account only. The value of the first"));
printf (" %s\n\n", _("column in the first row is used as the check result."));
printf (" %s\n", _("column in the first row is used as the check result. If a second column is"));
printf (" %s\n", _("present in the result set, this is added to the plugin output with a"));
printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system"));
printf (" %s\n\n", _("executing the plugin."));
printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
@ -557,6 +560,7 @@ do_query (PGconn *conn, char *query)
PGresult *res;
char *val_str;
char *extra_info;
double value;
char *endptr = NULL;
@ -621,6 +625,12 @@ do_query (PGconn *conn, char *query)
printf ("|query=%f;%s;%s;;\n", value,
query_warning ? query_warning : "",
query_critical ? query_critical : "");
if (PQnfields (res) > 1) {
extra_info = PQgetvalue (res, 0, 1);
if (extra_info != NULL) {
printf ("Extra Info: %s\n", extra_info);
}
}
return my_status;
}

View file

@ -3,7 +3,7 @@
* Monitoring check_smtp plugin
*
* License: GPL
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
* Copyright (c) 2000-2023 Monitoring Plugins Development Team
*
* Description:
*
@ -52,6 +52,7 @@ int days_till_exp_warn, days_till_exp_crit;
enum {
SMTP_PORT = 25
};
#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n"
#define SMTP_EXPECT "220"
#define SMTP_HELO "HELO "
#define SMTP_EHLO "EHLO "
@ -102,6 +103,8 @@ double critical_time = 0;
int check_critical_time = FALSE;
int verbose = 0;
int use_ssl = FALSE;
int use_sni = FALSE;
short use_proxy_prefix = FALSE;
short use_ehlo = FALSE;
short use_lhlo = FALSE;
short ssl_established = 0;
@ -184,6 +187,13 @@ main (int argc, char **argv)
if (result == STATE_OK) { /* we connected */
/* If requested, send PROXY header */
if (use_proxy_prefix) {
if (verbose)
printf ("Sending header %s\n", PROXY_PREFIX);
send(sd, PROXY_PREFIX, strlen(PROXY_PREFIX), 0);
}
/* watch for the SMTP connection string and */
/* return a WARNING status if we couldn't read any data */
if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
@ -225,7 +235,7 @@ main (int argc, char **argv)
smtp_quit();
return STATE_UNKNOWN;
}
result = np_net_ssl_init(sd);
result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
if(result != STATE_OK) {
printf (_("CRITICAL - Cannot create SSL context.\n"));
close(sd);
@ -454,6 +464,10 @@ process_arguments (int argc, char **argv)
int c;
char* temp;
enum {
SNI_OPTION
};
int option = 0;
static struct option longopts[] = {
{"hostname", required_argument, 0, 'H'},
@ -476,8 +490,10 @@ process_arguments (int argc, char **argv)
{"help", no_argument, 0, 'h'},
{"lmtp", no_argument, 0, 'L'},
{"starttls",no_argument,0,'S'},
{"sni", no_argument, 0, SNI_OPTION},
{"certificate",required_argument,0,'D'},
{"ignore-quit-failure",no_argument,0,'q'},
{"proxy",no_argument,0,'r'},
{0, 0, 0, 0}
};
@ -494,7 +510,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
longopts, &option);
if (c == -1 || c == EOF)
@ -621,6 +637,16 @@ process_arguments (int argc, char **argv)
use_ssl = TRUE;
use_ehlo = TRUE;
break;
case SNI_OPTION:
#ifdef HAVE_SSL
use_sni = TRUE;
#else
usage (_("SSL support not available - install OpenSSL and recompile"));
#endif
break;
case 'r':
use_proxy_prefix = TRUE;
break;
case 'L':
use_lhlo = TRUE;
break;
@ -819,11 +845,15 @@ print_help (void)
printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
printf (" %s\n", "-F, --fqdn=STRING");
printf (" %s\n", _("FQDN used for HELO"));
printf (" %s\n", "-r, --proxy");
printf (" %s\n", _("Use PROXY protocol prefix for the connection."));
#ifdef HAVE_SSL
printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
printf (" %s\n", "-S, --starttls");
printf (" %s\n", _("Use STARTTLS for the connection."));
printf (" %s\n", "--sni");
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
#endif
printf (" %s\n", "-A, --authtype=STRING");
@ -860,6 +890,6 @@ print_usage (void)
printf ("%s\n", _("Usage:"));
printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n");
}

View file

@ -44,6 +44,8 @@
# include <sys/wait.h>
#endif
#include "./utils.h"
/** macros **/
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)

3104
po/de.po

File diff suppressed because it is too large Load diff

3030
po/fr.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff