[Openvas-commits] r2915 - in trunk/openvas-client: . nessus

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Mar 26 11:47:56 CET 2009


Author: felix
Date: 2009-03-26 11:47:56 +0100 (Thu, 26 Mar 2009)
New Revision: 2915

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/plugin_infos.c
Log:
* nessus/plugin_infos.c (show_deps): Use glib string functions instead
of strcat and strcpy.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-26 10:23:52 UTC (rev 2914)
+++ trunk/openvas-client/ChangeLog	2009-03-26 10:47:56 UTC (rev 2915)
@@ -1,5 +1,10 @@
 2009-03-26  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	* nessus/plugin_infos.c (show_deps): Use glib string functions instead
+	of strcat and strcpy.
+
+2009-03-26  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	* nessus/nbe_output.c, nessus/nbe_output.h (nbe_to_backend): Declared
 	parameter as const.
 	

Modified: trunk/openvas-client/nessus/plugin_infos.c
===================================================================
--- trunk/openvas-client/nessus/plugin_infos.c	2009-03-26 10:23:52 UTC (rev 2914)
+++ trunk/openvas-client/nessus/plugin_infos.c	2009-03-26 10:47:56 UTC (rev 2915)
@@ -35,7 +35,7 @@
 
 #include <includes.h>
 
-#ifdef USE_GTK 
+#ifdef USE_GTK
 #include "gtk-compat.h"
 #include <gtk/gtk.h>
 
@@ -64,8 +64,7 @@
   GtkWidget * w;
   struct arglist * deps;
   gchar* lbl = NULL;
-  int label_size = 1024;
-  char * label;
+  char * label = NULL;
   lbl = g_strdup_printf (_("Dependencies of Plugin '%s'"), name);
 
   dialog = gtk_dialog_new_with_buttons(lbl, window,
@@ -92,13 +91,10 @@
 
   deps = arg_get_value(Context->dependencies, name);
 
-  label = emalloc(label_size);
-
   /* In case we find no dependencies, create a hint on this */
   if (!deps || !deps->next)
   {
-    strncpy(label, _("No dependencies found."), label_size);
-    w = gtk_label_new(label);
+    w = gtk_label_new (_("No dependencies found."));
     gtk_box_pack_start(GTK_BOX(vbox), w,   TRUE, TRUE, 2);
     gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
     gtk_widget_show(w);
@@ -111,34 +107,26 @@
     if(p == NULL)
       p = nessus_plugin_get_by_name(Context->scanners, deps->name);
 
-    if(p != NULL )
-    {
-      char * family = p->family;
-      if(strlen(deps->name) + strlen(family) + 255 > label_size)
+    if (p != NULL )
       {
-        label_size *= 2;
-        label = erealloc(label, label_size);
+        // Like "Identify unknown Services (Sevice Detection), currently disabled";
+        char* curr_disenabled = (p->enabled != 0) ?
+                                                    _(", currently enabled")
+                                                  : _(", currently disabled");
+        label = g_strdup_printf ("%s (%s), %s.", deps->name, p->family, curr_disenabled);
+        free (&curr_disenabled);
+        w = gtk_label_new (label);
       }
-      strncpy(label, deps->name, label_size);
-      strncat(label, " (", label_size);
-      strncat(label, family, label_size);
-      strncat(label, _("), currently "), label_size);
-      if (p->enabled != 0 )
-        strncat(label, _("enabled"), label_size);
-      else
-        strncat(label, _("disabled"), label_size);
-    }
-    else
-      strncpy(label, deps->name, label_size);
-    w = gtk_label_new(label);
+    else // like "Identify unknown Services"
+      w = gtk_label_new (deps->name);
+
     gtk_box_pack_start(GTK_BOX(vbox), w,   TRUE, TRUE, 2);
     gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
     gtk_widget_show(w);
     deps = deps->next;
+    g_free (label);
   }
 
-  efree(&label);
-
   /* execute and later remove the dialog */
   gtk_dialog_run(GTK_DIALOG(dialog));
   gtk_widget_destroy(dialog);
@@ -251,7 +239,7 @@
 }
 
 /**
- * Creates an untrusted certificate of owner "Unknown" with fingerprint fpr.
+ * @brief Creates an untrusted certificate of owner "Unknown" with fingerprint fpr.
  * 
  * @param fpr Fingerprint of certificate.
  * 



More information about the Openvas-commits mailing list