diff --git a/CHANGELOG.md b/CHANGELOG.md index ae11a49c1..7505941e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add option --optimize migrate-relay-sensors [#827](https://github.com/greenbone/gvmd/pull/827) - Add host_id filter for tls_certificates [#835](https://github.com/greenbone/gvmd/pull/835) - Allow use of public key auth in SCP alert [#845](https://github.com/greenbone/gvmd/pull/845) -- Refuse to import config with missing NVT preference ID [#856](https://github.com/greenbone/gvmd/pull/856) +- Refuse to import config with missing NVT preference ID [#856](https://github.com/greenbone/gvmd/pull/856) [#860](https://github.com/greenbone/gvmd/pull/860) ### Changed - Extend command line options for managing scanners [#815](https://github.com/greenbone/gvmd/pull/815) diff --git a/src/gmp_configs.c b/src/gmp_configs.c index f40c737cf..d5ebc836b 100644 --- a/src/gmp_configs.c +++ b/src/gmp_configs.c @@ -177,6 +177,30 @@ attr_or_null (entity_t entity, const gchar *name) return NULL; } +/** + * @brief Cleanup preferences array. + * + * @param[in] import_preferences Import preferences. + */ +static void +cleanup_import_preferences (array_t *import_preferences) +{ + if (import_preferences) + { + guint index; + + for (index = 0; index < import_preferences->len; index++) + { + preference_t *pref; + pref = (preference_t*) g_ptr_array_index (import_preferences, + index); + if (pref) + preference_free (pref); + } + g_ptr_array_free (import_preferences, TRUE); + } +} + /** * @brief Execute command. * @@ -347,7 +371,19 @@ create_config_run (gmp_parser_t *gmp_parser, GError **error) __FUNCTION__, preference_nvt_oid, preference_name); - new_preference = NULL; + + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("create_config", + "Error in PREFERENCES element.")); + log_event_fail ("config", "Scan config", NULL, "created"); + + /* Cleanup. */ + + cleanup_import_preferences (import_preferences); + array_free (import_nvt_selectors); + + create_config_reset (); + return; } } else @@ -448,21 +484,7 @@ create_config_run (gmp_parser_t *gmp_parser, GError **error) /* Cleanup. */ - if (import_preferences) - { - guint index; - - for (index = 0; index < import_preferences->len; index++) - { - preference_t *pref; - pref = (preference_t*) g_ptr_array_index (import_preferences, - index); - if (pref) - preference_free (pref); - } - g_ptr_array_free (import_preferences, TRUE); - } - + cleanup_import_preferences (import_preferences); array_free (import_nvt_selectors); create_config_reset ();