Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also check IDs when setting prefs for CREATE_CONFIG (9.0) #860

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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