[Nagiosplug-devel] segfault in plugin check_nt and solution / patch

Olli Hauer sfnetmail at nurfuerspam.de
Fri Nov 7 21:11:09 CET 2008


Hi,

in the plugin check_nt there is a wrong handling that cause the plugin segfault.

I have already created a bug report with patch, but no feedback until now.
http://sourceforge.net/tracker/?func=detail&atid=397599&aid=2179754&group_id=29880
patch: http://sourceforge.net/tracker/download.php?group_id=29880&atid=397599&file_id=297946&aid=2179754


Since the probem is descriped in the bug report i want to hear if someon can confirm this.

the following lines (patch wo. formating to keep the code short) shows what should be changed in the code. for a correct formating (long patch) please grab the patch from the bug report.


Regards,
olli hauer

@@ -97,6 +97,8 @@
        char *temp_string_perf=NULL;
        char *description=NULL,*counter_unit = NULL;
        char *minval = NULL, *maxval = NULL, *errcvt = NULL;
+       char *fds=NULL;
+       char *tds=NULL;

        double total_disk_space=0;
        double free_disk_space=0;
@@ -218,8 +220,15 @@
                else {
                        asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
                        fetch_data (server_address, server_port, send_buffer);
-                       free_disk_space=atof(strtok(recv_buffer,"&"));
-                       total_disk_space=atof(strtok(NULL,"&"));
+                       fds=strtok(recv_buffer,"&");
+                       tds=strtok(NULL,"&");
+
+                       if (fds != NULL)
+                               free_disk_space=atof(fds);
+                       if (tds != NULL)
+                               total_disk_space=atof(tds);
+
+               if (total_disk_space>0) {
                        percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
                        warning_used_space = ((float)warning_value / 100) * total_disk_space;
                        critical_used_space = ((float)critical_value / 100) * total_disk_space;
@@ -241,7 +250,8 @@

                                output_message = strdup (temp_string);
                                perfdata = temp_string_perf;
-                       } else {
+                       }
+               } else {
                                output_message = strdup (_("Free disk space : Invalid drive "));
                                return_code=STATE_UNKNOWN;
                        }

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger




More information about the Devel mailing list