[Openvas-commits] r12228 - in trunk/gsa: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 30 18:38:23 CET 2011


Author: mattm
Date: 2011-11-30 18:38:22 +0100 (Wed, 30 Nov 2011)
New Revision: 12228

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
Log:
	* src/gsad_omp.c (get_report): Make sure commands_xml is always defined,
	because it is always freed.  Free levels.  Remove some cases where xml is
	freed erroneously.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-11-30 15:19:06 UTC (rev 12227)
+++ trunk/gsa/ChangeLog	2011-11-30 17:38:22 UTC (rev 12228)
@@ -1,5 +1,9 @@
 2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	* src/gsad_omp.c (init_validator): Allow space around numbers.
+
+2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	* src/html/omp.xsl (report [assets]): Only enable the Prognostic Report
 	icon when there is a prognosis.
 

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-11-30 15:19:06 UTC (rev 12227)
+++ trunk/gsa/src/gsad_omp.c	2011-11-30 17:38:22 UTC (rev 12228)
@@ -7681,9 +7681,9 @@
 
   /* Run any extra commands. */
 
+  commands_xml = g_string_new ("");
   if (commands)
     {
-      commands_xml = g_string_new ("");
       if (openvas_server_send (&session, commands)
           == -1)
         {
@@ -7859,6 +7859,7 @@
           openvas_server_close (socket, session);
           g_string_free (commands_xml, TRUE);
           g_string_free (delta_states, TRUE);
+          g_string_free (levels, TRUE);
           return gsad_message (credentials,
                                "Internal error", __FUNCTION__, __LINE__,
                                "An internal error occurred while getting a report. "
@@ -7872,6 +7873,7 @@
           openvas_server_close (socket, session);
           g_string_free (commands_xml, TRUE);
           g_string_free (delta_states, TRUE);
+          g_string_free (levels, TRUE);
           return gsad_message (credentials,
                                "Internal error", __FUNCTION__, __LINE__,
                                "An internal error occurred while getting a report. "
@@ -7910,6 +7912,7 @@
           openvas_server_close (socket, session);
           g_string_free (commands_xml, TRUE);
           g_string_free (delta_states, TRUE);
+          g_string_free (levels, TRUE);
           return ret;
         }
       free_entity (entity);
@@ -7990,6 +7993,7 @@
       openvas_server_close (socket, session);
       g_string_free (delta_states, TRUE);
       g_string_free (commands_xml, TRUE);
+      g_string_free (levels, TRUE);
       return gsad_message (credentials,
                            "Internal error", __FUNCTION__, __LINE__,
                            "An internal error occurred while getting a report. "
@@ -8003,6 +8007,7 @@
   if (format_id)
     {
       g_string_free (commands_xml, TRUE);
+      g_string_free (levels, TRUE);
       if (strcmp (format_id, "d5da9f67-8551-4e51-807b-b6a873d70e34") == 0)
         {
           const char *extension, *type;
@@ -8010,7 +8015,6 @@
 
           if (read_entity (&session, &entity))
             {
-              g_string_free (xml, TRUE);
               openvas_server_close (socket, session);
               return gsad_message (credentials,
                                    "Internal error", __FUNCTION__, __LINE__,
@@ -8024,7 +8028,6 @@
           if (report == NULL)
             {
               free_entity (entity);
-              g_string_free (xml, TRUE);
               return gsad_message (credentials,
                                    "Internal error", __FUNCTION__, __LINE__,
                                    "An internal error occurred while getting a report. "
@@ -8042,6 +8045,7 @@
                                    report_id,
                                    extension);
             }
+          xml = g_string_new ("");
           print_entity_to_string (report, xml);
           free_entity (entity);
           return g_string_free (xml, FALSE);
@@ -8050,8 +8054,6 @@
         {
           /* "nbe", "pdf", "dvi", "html", "html-pdf"... */
 
-          g_string_free (xml, TRUE);
-
           if (report_len == NULL)
             {
               return gsad_message (credentials,
@@ -8155,6 +8157,9 @@
               if (host_search_phrase == NULL)
                 {
                   openvas_server_close (socket, session);
+                  g_string_free (commands_xml, TRUE);
+                  g_string_free (levels, TRUE);
+                  g_string_free (xml, TRUE);
                   xml = g_string_new ("");
                   g_string_append_printf (xml, GSAD_MESSAGE_INVALID,
                                           "Given host search_phrase was invalid",
@@ -8188,10 +8193,9 @@
         xml = g_string_new ("<get_report>");
 
       if (commands)
-        {
-          g_string_append (xml, commands_xml->str);
-          g_string_free (commands_xml, TRUE);
-        }
+        g_string_append (xml, commands_xml->str);
+      g_string_free (commands_xml, TRUE);
+      g_string_free (levels, TRUE);
 
       if (strcmp (escalator_id, "0"))
         g_string_append_printf (xml, "<get_reports_escalate_response"
@@ -8208,7 +8212,6 @@
       if (read_entity_and_string (&session, &entity, &xml))
         {
           openvas_server_close (socket, session);
-          g_string_free (commands_xml, TRUE);
           return gsad_message (credentials,
                                "Internal error", __FUNCTION__, __LINE__,
                                "An internal error occurred while getting a report. "
@@ -8221,7 +8224,6 @@
         {
           g_string_append (xml, "</get_prognostic_report>");
           openvas_server_close (socket, session);
-          g_string_free (commands_xml, TRUE);
           return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
         }
 
@@ -8232,7 +8234,6 @@
           else
             g_string_append (xml, "</get_report>");
           openvas_server_close (socket, session);
-          g_string_free (commands_xml, TRUE);
           return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
         }
 



More information about the Openvas-commits mailing list