Browse Source

Merge pull request #485 from sawolf/446-solaris-overflow

Resolve #446 - check_procs crash due to buffer overflow on solaris
Sebastian Wolf 6 năm trước cách đây
mục cha
commit
f4944cb281
3 tập tin đã thay đổi với 11 bổ sung2 xóa
  1. 1 0
      THANKS.in
  2. 1 1
      configure.ac
  3. 9 1
      plugins-root/pst3.c

+ 1 - 0
THANKS.in

@@ -50,6 +50,7 @@ Brian De Wolf
 Brian Landers
 brigriffin
 Bryan Irvine
+Bryan Leaman
 Carlos Canau
 Carole Verdon
 cejkar

+ 1 - 1
configure.ac

@@ -682,7 +682,7 @@ elif test "$ac_cv_uname_s" = "SunOS"; then
                 pst3="$libexecdir/pst3"
         fi
         ac_cv_ps_command="$pst3"
-        ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
+        ac_cv_ps_format="%7s %d %d %d %d %d %f %s %n"
         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
         ac_cv_ps_cols=9
         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])

+ 9 - 1
plugins-root/pst3.c

@@ -227,7 +227,15 @@ try_again:
         i--;
         continue;
       }
-      printf(" %s", args);
+
+      /* Remove newlines from args output - consistent with "normal" ps */
+      printf(" ");
+      for (j=0;j<strlen(args);j++) {
+        if (args[j] != '\n') {
+          printf("%c", args[j]);
+        }
+      }
+
     }
     free(args_vecs);
     free(args);