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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 13 13:43:37 CEST 2009


Author: felix
Date: 2009-10-13 13:43:36 +0200 (Tue, 13 Oct 2009)
New Revision: 5511

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/openvas/attack.c
   trunk/openvas-client/openvas/comm.c
   trunk/openvas-client/openvas/comm.h
Log:
* openvas/comm.c (omp_send_files)[USE_OMP]: Closed mem leaks, changed
signature to return whether action was successfull.
openvas/comm.h: Adjusted proto.

* openvas/attack.c (attack_host)[USE_OMP]: Respect (new) return value
of omp_send_files.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-10-13 11:33:41 UTC (rev 5510)
+++ trunk/openvas-client/ChangeLog	2009-10-13 11:43:36 UTC (rev 5511)
@@ -1,5 +1,14 @@
 2009-10-13  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	* openvas/comm.c (omp_send_files)[USE_OMP]: Closed mem leaks, changed
+	signature to return whether action was successfull.
+	openvas/comm.h: Adjusted proto.
+
+	* openvas/attack.c (attack_host)[USE_OMP]: Respect (new) return value
+	of omp_send_files.
+
+2009-10-13  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Minor refactoring.
 
 	* openvas/comm.c (omp_send_files)[USE_OMP]: New, moved from atttack.c

Modified: trunk/openvas-client/openvas/attack.c
===================================================================
--- trunk/openvas-client/openvas/attack.c	2009-10-13 11:33:41 UTC (rev 5510)
+++ trunk/openvas-client/openvas/attack.c	2009-10-13 11:43:36 UTC (rev 5511)
@@ -167,7 +167,8 @@
       }
 
       /* Send files, in case they are newer. */
-      omp_send_files (context, socket, session);
+      if (omp_send_files (context, socket, session) == FALSE)
+        return 0;
 
       /* Start the task. */
 

Modified: trunk/openvas-client/openvas/comm.c
===================================================================
--- trunk/openvas-client/openvas/comm.c	2009-10-13 11:33:41 UTC (rev 5510)
+++ trunk/openvas-client/openvas/comm.c	2009-10-13 11:43:36 UTC (rev 5511)
@@ -262,14 +262,17 @@
  * @param socket  The socket to send data over.
  * @param session The GnuTLS session to the server.
  *
- * @return Always zero.
+ * @return TRUE in case of success, FALSE otherwise. In the 'fail' case, an
+ *         error message will be shown and the socket will be closed.
  */
-int
+gboolean
 omp_send_files (struct context* context, int socket, gnutls_session_t session)
 {
   GSList *files = NULL;
+  GSList *file = NULL;
   struct openvas_plugin *plugins[2];
   int i;
+  gboolean success = TRUE;
 
   /* Collect the files. */
   plugins[0] = context->plugins;
@@ -300,48 +303,55 @@
     }
 
   /* Send the files. */
-  while (files)
+  file = files;
+  while (file)
     {
-      GSList *last = files;
       gchar *content;
       gsize content_len;
       GError *error;
 
-      if (files->data && strlen (files->data))
+      if (file->data && strlen (file->data))
         {
           error = NULL;
-          g_file_get_contents (files->data, &content, &content_len, &error);
+          g_file_get_contents (file->data, &content, &content_len, &error);
           if (error)
             {
               show_error (_("Error getting contents of '%s': %s"),
-                          files->data,
+                          file->data,
                           error->message);
               g_error_free (error);
               openvas_server_close (socket, session);
-              // FIX free list incl data
-              return 0;
+              success = FALSE;
+              break;
             }
 
           if (omp_modify_task_file (&session,
                                     prefs_get_string (context, "id"),
-                                    files->data,
+                                    file->data,
                                     content))
             {
-              show_error (_("Failed to set file on task: '%s'"), files->data);
+              show_error (_("Failed to set file on task: '%s'"), file->data);
               g_free (content);
               openvas_server_close (socket, session);
-              // FIX free list incl data
-              return 0;
+              success = FALSE;
+              break;
             }
           g_free (content);
         }
 
-      files = g_slist_next (files);
-      g_free (last->data);
-      g_slist_free_1 (last);
+      file = g_slist_next (file);
     }
 
-  return 0;
+  /* Free list and content */
+  file = files;
+  while (file)
+    {
+      g_free (file->data);
+      file = g_slist_next (file);
+    }
+  g_slist_free (files);
+
+  return success;
 }
 #endif
 

Modified: trunk/openvas-client/openvas/comm.h
===================================================================
--- trunk/openvas-client/openvas/comm.h	2009-10-13 11:33:41 UTC (rev 5510)
+++ trunk/openvas-client/openvas/comm.h	2009-10-13 11:43:36 UTC (rev 5511)
@@ -56,7 +56,7 @@
 GSList* send_ssh_credential_files (GSList* files_to_send);
 
 #ifdef USE_OMP
-int omp_send_files (struct context* context, int socket, gnutls_session_t session);
+gboolean omp_send_files (struct context* context, int socket, gnutls_session_t session);
 #endif
 
 #endif



More information about the Openvas-commits mailing list