Skip to content

Commit

Permalink
Merge pull request #860 from mattmundell/refuse-old-configs-gmp-9.0
Browse files Browse the repository at this point in the history
Also check IDs when setting prefs for CREATE_CONFIG (9.0)
  • Loading branch information
timopollmeier authored Nov 7, 2019
2 parents 39c7698 + 5f2071b commit 4b7ebb7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 38 additions & 16 deletions src/gmp_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ();
Expand Down

0 comments on commit 4b7ebb7

Please sign in to comment.