Просмотр исходного кода

plugins-root/check_icmp.c: fix unsigned short overflow

The number of targets (hosts) for check_icmp is tallied up, one at a
time, in

  static unsigned short targets = 0;

When more than USHRT_MAX hosts are specified, check_icmp segfaults
before dropping privileges. This may be exploitable, and is bad in any
case. The same issue was recently fixed in monitoring-plugins:

  https://www.openwall.com/lists/oss-security/2026/07/01/5

The two codebases have diverged, but the issue is easy to reproduce in
nagios-plugins as well. Afterwards, fixing it is a matter of refusing
to add_target() when there are already USHRT_MAX targets.
Michael Orlitzky 4 месяцев назад
Родитель
Сommit
c94e36bd08
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      plugins-root/check_icmp.c

+ 5 - 0
plugins-root/check_icmp.c

@@ -1705,6 +1705,11 @@ static int add_target_ip(char *arg, struct sockaddr_storage *in) {
   struct sockaddr_in *sin = NULL, *host_sin;
   struct sockaddr_in *sin = NULL, *host_sin;
   struct sockaddr_in6 *sin6 = NULL, *host_sin6;
   struct sockaddr_in6 *sin6 = NULL, *host_sin6;
 
 
+  if (targets == USHRT_MAX) {
+    crash("add_target_ip(%s, ...): maximum number of targets (%hu) exceeded",
+	  arg, USHRT_MAX);
+  }
+
   if (address_family == AF_INET) {
   if (address_family == AF_INET) {
     sin = (struct sockaddr_in *)in;
     sin = (struct sockaddr_in *)in;
   } else {
   } else {