Author: bricks
Date: 2016-10-13 08:24:53 +0200 (Thu, 13 Oct 2016)
New Revision: 26393

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
Log:
* src/gsad_omp.c (create_target_omp): Add check for submitted file if
target_source is file.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog 2016-10-13 06:19:49 UTC (rev 26392)
+++ trunk/gsa/ChangeLog 2016-10-13 06:24:53 UTC (rev 26393)
@@ -1,5 +1,10 @@
 2016-10-13 Bj�rn Ricks <bjoern.ri...@greenbone.net>
 
+       * src/gsad_omp.c (create_target_omp): Add check for submitted file if
+       target_source is file.
+
+2016-10-13 Bj�rn Ricks <bjoern.ri...@greenbone.net>
+
        * src/html/classic/omp.xsl (html-create-target-form): Use 0 instead of 
-- as
        default credential ids. This commit fixes the last missing select 
options in
        this form.

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c    2016-10-13 06:19:49 UTC (rev 26392)
+++ trunk/gsa/src/gsad_omp.c    2016-10-13 06:24:53 UTC (rev 26393)
@@ -9659,7 +9659,7 @@
   const char *target_ssh_credential, *port, *target_smb_credential;
   const char *target_esxi_credential, *target_snmp_credential, *target_source;
   const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
-  const char *alive_tests, *hosts_filter;
+  const char *alive_tests, *hosts_filter, *file;
   gchar *ssh_credentials_element, *smb_credentials_element;
   gchar *esxi_credentials_element, *snmp_credentials_element;
   gchar *asset_hosts_element;
@@ -9683,6 +9683,7 @@
   target_snmp_credential = params_value (params, "snmp_credential_id");
   alive_tests = params_value (params, "alive_tests");
   hosts_filter = params_value (params, "hosts_filter");
+  file = params_value (params, "file");
 
   CHECK_PARAM_INVALID (name, "Create Target", "new_target");
   CHECK_PARAM_INVALID (target_source, "Create Target", "new_target")
@@ -9691,6 +9692,11 @@
                             "Missing manual list of hosts",
                             G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
                             "Create Target", "new_target");
+  if (strcmp (target_source, "file") == 0 && file == NULL)
+    return message_invalid (credentials, params, response_data,
+                            "Missing hosts file",
+                            G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
+                            "Create Target", "new_target");
 
   /* require hosts_filter if target_source is "asset_hosts" */
   if (strcmp (target_source, "asset_hosts") == 0)
@@ -9761,9 +9767,7 @@
                      "<port_list id=\"%s\"/>"
                      "<alive_tests>%s</alive_tests>",
                      name,
-                     strcmp (target_source, "file") == 0
-                      ? params_value (params, "file")
-                      : hosts,
+                     strcmp (target_source, "file") == 0 ? file : hosts,
                      exclude_hosts ? exclude_hosts : "",
                      reverse_lookup_only ? reverse_lookup_only : "0",
                      reverse_lookup_unify ? reverse_lookup_unify : "0",

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

Reply via email to