[Openvas-commits] r9113 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 29 15:45:27 CEST 2010


Author: mattm
Date: 2010-09-29 15:45:25 +0200 (Wed, 29 Sep 2010)
New Revision: 9113

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.c
   trunk/openvas-manager/src/omp.c
Log:
	Ensure GET_SYSTEM_REPORTS responds properly when the given type is
	missing.

	* src/manage.c (get_system_report_types): Return 1 on failure to find
	report.  Always init types args when getting all reports.
	(init_system_report_type_iterator): Add fail returns.

	* src/manage.h: Update headers accordingly.

	* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_SYSTEM_REPORTS
	correct error response variable and bring line width in range.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2010-09-29 11:56:35 UTC (rev 9112)
+++ trunk/openvas-manager/ChangeLog	2010-09-29 13:45:25 UTC (rev 9113)
@@ -1,3 +1,17 @@
+2010-09-29  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Ensure GET_SYSTEM_REPORTS responds properly when the given type is
+	missing.
+
+	* src/manage.c (get_system_report_types): Return 1 on failure to find
+	report.  Always init types args when getting all reports.
+	(init_system_report_type_iterator): Add fail returns.
+
+	* src/manage.h: Update headers accordingly.
+
+	* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_SYSTEM_REPORTS
+	correct error response variable and bring line width in range.
+
 2010-09-28  Matthew Mundell <matthew.mundell at greenbone.net>
 
 	Extend GET_SYSTEM_REPORTS for getting slave system reports.

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2010-09-29 11:56:35 UTC (rev 9112)
+++ trunk/openvas-manager/src/manage.c	2010-09-29 13:45:25 UTC (rev 9113)
@@ -2541,7 +2541,8 @@
  * @param[out]  start          Actual start of types, which caller must free.
  * @param[out]  slave_id       ID of slave.
  *
- * @return 0 if successful, 2 failed to find slave, -1 otherwise.
+ * @return 0 if successful, 1 failed to find report type, 2 failed to find
+ *         slave, -1 otherwise.
  */
 static int
 get_system_report_types (const char *required_type, gchar ***start,
@@ -2613,12 +2614,14 @@
       if (required_type)
         {
           /* Failed to find the single given type. */
+          g_free (astdout);
+          g_free (astderr);
           g_strfreev (*types);
-          *start = *types = NULL;
+          return 1;
         }
     }
   else
-    *start = *types = NULL;
+    *start = *types = g_malloc0 (sizeof (gchar*));
 
   g_free (astdout);
   g_free (astderr);
@@ -2634,16 +2637,19 @@
  * @param[in]  type        Single report type to iterate over, NULL for all.
  * @param[in]  slave_id    ID of slave to get reports from.  0 for local.
  *
- * @return 0 on success, -1 on error.
+ * @return 0 on success, 1 failed to find report type, 2 failed to find slave,
+ *         -1 on error.
  */
 int
 init_system_report_type_iterator (report_type_iterator_t* iterator,
                                   const char* type,
                                   const char* slave_id)
 {
-  if (get_system_report_types (type, &iterator->start, &iterator->current,
-                               slave_id))
-    return -1;
+  int ret;
+  ret = get_system_report_types (type, &iterator->start, &iterator->current,
+                                 slave_id);
+  if (ret)
+    return ret;
   iterator->current--;
   return 0;
 }

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2010-09-29 11:56:35 UTC (rev 9112)
+++ trunk/openvas-manager/src/omp.c	2010-09-29 13:45:25 UTC (rev 9113)
@@ -13287,7 +13287,7 @@
               case 1:
                 if (send_find_error_to_client ("get_system_reports",
                                                "system report",
-                                               get_targets_data->target_id,
+                                               get_system_reports_data->name,
                                                write_to_client,
                                                write_to_client_data))
                   {
@@ -13296,11 +13296,12 @@
                   }
                 break;
               case 2:
-                if (send_find_error_to_client ("get_system_reports",
-                                               "slave",
-                                               get_system_reports_data->slave_id,
-                                               write_to_client,
-                                               write_to_client_data))
+                if (send_find_error_to_client
+                     ("get_system_reports",
+                      "slave",
+                      get_system_reports_data->slave_id,
+                      write_to_client,
+                      write_to_client_data))
                   {
                     error_send_to_client (error);
                     return;



More information about the Openvas-commits mailing list