Author: timopollmeier
Date: 2016-10-12 11:56:55 +0200 (Wed, 12 Oct 2016)
New Revision: 26377

Modified:
   branches/openvas-manager-6.0/ChangeLog
   branches/openvas-manager-6.0/src/manage_sql.c
Log:
        Backport r26371 and r26374.

        * src/manage_sql.c (print_report_xml): Create hash tables shortly
        before they are used and destroy them when no longer needed.  Also
        rename elements ports and results in hosts to port_count and
        result_count.

Modified: branches/openvas-manager-6.0/ChangeLog
===================================================================
--- branches/openvas-manager-6.0/ChangeLog      2016-10-12 09:56:01 UTC (rev 
26376)
+++ branches/openvas-manager-6.0/ChangeLog      2016-10-12 09:56:55 UTC (rev 
26377)
@@ -1,3 +1,12 @@
+2016-10-12  Timo Pollmeier <timo.pollme...@greenbone.net>
+
+       Backport r26371 and r26374.
+
+       * src/manage_sql.c (print_report_xml): Create hash tables shortly
+       before they are used and destroy them when no longer needed.  Also
+       rename elements ports and results in hosts to port_count and
+       result_count.
+
 2016-10-11  Timo Pollmeier <timo.pollme...@greenbone.net>
 
        Backport r26358.

Modified: branches/openvas-manager-6.0/src/manage_sql.c
===================================================================
--- branches/openvas-manager-6.0/src/manage_sql.c       2016-10-12 09:56:01 UTC 
(rev 26376)
+++ branches/openvas-manager-6.0/src/manage_sql.c       2016-10-12 09:56:55 UTC 
(rev 26377)
@@ -25640,16 +25640,11 @@
   orig_filtered_result_count = 0;
   orig_f_false_positives = orig_f_warnings = orig_f_logs = orig_f_infos = 0;
   orig_f_holes = orig_f_debugs = 0;
-  f_host_ports = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                        g_free, NULL);
-  f_host_holes = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                        g_free, NULL);
-  f_host_warnings = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                           g_free, NULL);
-  f_host_infos = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                      g_free, NULL);
-  f_host_logs = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                      g_free, NULL);
+  f_host_ports = NULL;
+  f_host_holes = NULL;
+  f_host_warnings = NULL;
+  f_host_infos = NULL;
+  f_host_logs = NULL;
   f_host_false_positives = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                   g_free, NULL);
 
@@ -26305,6 +26300,9 @@
 
   /* Port summary. */
 
+  f_host_ports = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                        g_free, NULL);
+
   if (get->details && (delta == 0))
     {
       if (print_report_port_xml (report, out,
@@ -26316,6 +26314,7 @@
                                  f_host_ports))
         {
           tz_revert (zone, tz);
+          g_hash_table_destroy (f_host_ports);
           return -1;
         }
     }
@@ -26438,6 +26437,18 @@
   else
     /* Quiet erroneous compiler warning. */
     result_hosts = NULL;
+
+  f_host_holes = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                        g_free, NULL);
+  f_host_warnings = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                           g_free, NULL);
+  f_host_infos = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                      g_free, NULL);
+  f_host_logs = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                      g_free, NULL);
+  f_host_false_positives = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                                  g_free, NULL);
+
   if (delta && get->details)
     {
       gboolean done, delta_done;
@@ -26674,6 +26685,12 @@
               cleanup_iterator (&results);
               cleanup_iterator (&delta_results);
               tz_revert (zone, tz);
+              g_hash_table_destroy (f_host_ports);
+              g_hash_table_destroy (f_host_holes);
+              g_hash_table_destroy (f_host_warnings);
+              g_hash_table_destroy (f_host_infos);
+              g_hash_table_destroy (f_host_logs);
+              g_hash_table_destroy (f_host_false_positives);
               return -1;
             }
           PRINT_XML (out, buffer->str);
@@ -26977,6 +26994,12 @@
               cleanup_iterator (&results);
               cleanup_iterator (&delta_results);
               tz_revert (zone, tz);
+              g_hash_table_destroy (f_host_ports);
+              g_hash_table_destroy (f_host_holes);
+              g_hash_table_destroy (f_host_warnings);
+              g_hash_table_destroy (f_host_infos);
+              g_hash_table_destroy (f_host_logs);
+              g_hash_table_destroy (f_host_false_positives);
               return -1;
             }
 
@@ -27282,15 +27305,15 @@
                      "<ip>%s</ip>"
                      "<start>%s</start>"
                      "<end>%s</end>"
-                     "<ports><page>%d</page></ports>"
-                     "<results>"
+                     "<port_count><page>%d</page></port_count>"
+                     "<result_count>"
                      "<page>%d</page>"
                      "<hole><page>%d</page></hole>"
                      "<warning><page>%d</page></warning>"
                      "<info><page>%d</page></info>"
                      "<log><page>%d</page></log>"
                      "<false_positive><page>%d</page></false_positive>"
-                     "</results>",
+                     "</result_count>",
                      host,
                      host_iterator_start_time (&hosts),
                      host_iterator_end_time (&hosts)
@@ -27311,6 +27334,12 @@
                   tz_revert (zone, tz);
                   if (host_summary_buffer)
                     g_string_free (host_summary_buffer, TRUE);
+                  g_hash_table_destroy (f_host_ports);
+                  g_hash_table_destroy (f_host_holes);
+                  g_hash_table_destroy (f_host_warnings);
+                  g_hash_table_destroy (f_host_infos);
+                  g_hash_table_destroy (f_host_logs);
+                  g_hash_table_destroy (f_host_false_positives);
                   return -1;
                 }
 
@@ -27377,15 +27406,15 @@
                  "<ip>%s</ip>"
                  "<start>%s</start>"
                  "<end>%s</end>"
-                 "<ports><page>%d</page></ports>"
-                 "<results>"
+                 "<port_count><page>%d</page></port_count>"
+                 "<result_count>"
                  "<page>%d</page>"
                  "<hole><page>%d</page></hole>"
                  "<warning><page>%d</page></warning>"
                  "<info><page>%d</page></info>"
                  "<log><page>%d</page></log>"
                  "<false_positive><page>%d</page></false_positive>"
-                 "</results>",
+                 "</result_count>",
                  host_iterator_host (&hosts),
                  host_iterator_start_time (&hosts),
                  host_iterator_end_time (&hosts)
@@ -27406,6 +27435,12 @@
               tz_revert (zone, tz);
               if (host_summary_buffer)
                 g_string_free (host_summary_buffer, TRUE);
+              g_hash_table_destroy (f_host_ports);
+              g_hash_table_destroy (f_host_holes);
+              g_hash_table_destroy (f_host_warnings);
+              g_hash_table_destroy (f_host_infos);
+              g_hash_table_destroy (f_host_logs);
+              g_hash_table_destroy (f_host_false_positives);
               return -1;
             }
 
@@ -27429,6 +27464,14 @@
                   : "");
       cleanup_iterator (&hosts);
     }
+
+  g_hash_table_destroy (f_host_ports);
+  g_hash_table_destroy (f_host_holes);
+  g_hash_table_destroy (f_host_warnings);
+  g_hash_table_destroy (f_host_infos);
+  g_hash_table_destroy (f_host_logs);
+  g_hash_table_destroy (f_host_false_positives);
+
   end_time = scan_end_time (report);
   PRINT (out,
            "<scan_end>%s</scan_end>",

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to