[Openvas-commits] r1329 - in branches/openvas-client-1-0: . nessus

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 11 14:02:49 CEST 2008


Author: timb
Date: 2008-09-11 14:02:49 +0200 (Thu, 11 Sep 2008)
New Revision: 1329

Modified:
   branches/openvas-client-1-0/ChangeLog
   branches/openvas-client-1-0/nessus/monitor_dialog.c
Log:
Backport from trunk. Fixed #758, which leads to an OpenVAS client crash due to a divide by zero


Modified: branches/openvas-client-1-0/ChangeLog
===================================================================
--- branches/openvas-client-1-0/ChangeLog	2008-09-10 23:44:50 UTC (rev 1328)
+++ branches/openvas-client-1-0/ChangeLog	2008-09-11 12:02:49 UTC (rev 1329)
@@ -1,3 +1,10 @@
+2008-09-11  Tim Brown <timb at nth-dimension.org.uk>
+
+	Backport from trunk.
+
+	* nessus/monitor_dialog.c: Fixed #758, which leads to an OpenVAS client
+	crash due to a divide by zero.
+
 2008-08-22  Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
 
 	Backport from trunk.

Modified: branches/openvas-client-1-0/nessus/monitor_dialog.c
===================================================================
--- branches/openvas-client-1-0/nessus/monitor_dialog.c	2008-09-10 23:44:50 UTC (rev 1328)
+++ branches/openvas-client-1-0/nessus/monitor_dialog.c	2008-09-11 12:02:49 UTC (rev 1329)
@@ -376,9 +376,14 @@
   if (GTK_CHECK_VERSION(2,6,0)) { /* TreeView since GTK 2.6 */
     GtkListStore * store = arg_get_value(ctrls, "MON_STORE");
     GtkTreeIter iter;
-    int f = (atoi(current) * 100) / max;
-    if(f>=100)f=100;
-    if(f<=0)f=0;
+    int f;
+    if (max == 0) {
+      f = 100;
+    } else {
+      f = (atoi(current) / max) * 100;
+      if(f>=100)f=100;
+      if(f<=0)f=0;
+    }
 
     if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) {
       do {
@@ -415,16 +420,21 @@
         GtkWidget * progress_bar;
         gfloat f;
    
+        gmax = max;
+	if (gmax == 0) {
+          f = 1.0;
+        } else {
+          gcurrent = atoi(current);
+          f = (gcurrent/gmax);
+          if(f>=1.0)f=1.0;
+          if(f<=0.0)f=0.0;
+        }
+
         if( strcmp(action, "portscan") == 0 )
           progress_bar = gtk_object_get_data(item, "progress_bar_portscan");
         else
           progress_bar = gtk_object_get_data(item, "progress_bar_attack");
 
-        gmax = max;
-        gcurrent = atoi(current);
-        f = (gcurrent/gmax);
-        if(f>=1.0)f=1.0;
-        if(f<=0.0)f=0.0;
         gtk_progress_bar_update (GTK_PROGRESS_BAR(progress_bar), f);
 
         flag = 1;



More information about the Openvas-commits mailing list