From b4a6a1d229dbfa552f329fe20b06dc6fb6c716d5 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Tue, 30 Jul 2019 21:35:19 +0200 Subject: [PATCH 1/2] Use API for accessing NVTI elements. The NVTI object should not be accessed directly via its elements. The API are the methods, not the struct. --- nasl/nasl_scanner_glue.c | 10 ++++------ src/attack.c | 4 ++-- src/pluginlaunch.c | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/nasl/nasl_scanner_glue.c b/nasl/nasl_scanner_glue.c index 5433881f8..97fa0f851 100644 --- a/nasl/nasl_scanner_glue.c +++ b/nasl/nasl_scanner_glue.c @@ -454,27 +454,25 @@ script_add_preference (lex_ctxt *lexic) char *value = get_str_var_by_name (lexic, "value"); struct script_infos *script_infos = lexic->script_infos; nvtpref_t *np; - GSList *tmp; + unsigned int i; if (!script_infos->nvti) return FAKE_CELL; if (id <= 0) - id = g_slist_length (script_infos->nvti->prefs) + 1; + id = nvti_pref_len (script_infos->nvti) + 1; if (!name || !type || !value) { nasl_perror (lexic, "Argument error in the call to script_add_preference()\n"); return FAKE_CELL; } - tmp = script_infos->nvti->prefs; - while (tmp) + for (i = 0; i < nvti_pref_len (script_infos->nvti); i ++) { - if (!strcmp (name, ((nvtpref_t *) tmp->data)->name)) + if (!strcmp (name, nvtpref_name (nvti_pref (script_infos->nvti,i)))) { nasl_perror (lexic, "Preference '%s' already exists\n", name); return FAKE_CELL; } - tmp = tmp->next; } np = nvtpref_new (id, name, type, value); diff --git a/src/attack.c b/src/attack.c index ee0f27773..a8c9eaf77 100644 --- a/src/attack.c +++ b/src/attack.c @@ -259,7 +259,7 @@ launch_plugin (struct scan_globals *globals, struct scheduler_plugin *plugin, } if (scan_is_stopped () || all_scans_are_stopped ()) { - if (nvti->category != ACT_END) + if (nvti_category (nvti) != ACT_END) { plugin->running_state = PLUGIN_STATUS_DONE; goto finish_launch_plugin; @@ -275,7 +275,7 @@ launch_plugin (struct scan_globals *globals, struct scheduler_plugin *plugin, if (network_scan_status (globals) == NSS_BUSY) network_scan = TRUE; - if (prefs_get_bool ("safe_checks") && !nvti_category_is_safe (nvti->category)) + if (prefs_get_bool ("safe_checks") && !nvti_category_is_safe (nvti_category (nvti))) { if (prefs_get_bool ("log_whole_attack")) { diff --git a/src/pluginlaunch.c b/src/pluginlaunch.c index bdafd62cf..b51906873 100644 --- a/src/pluginlaunch.c +++ b/src/pluginlaunch.c @@ -310,7 +310,7 @@ plugin_timeout (nvti_t *nvti) int timeout; assert (nvti); - timeout = prefs_nvt_timeout (nvti->oid); + timeout = prefs_nvt_timeout (nvti_oid (nvti)); if (timeout == 0) timeout = nvti_timeout (nvti); if (timeout == 0) From 85a9c43631d5cafe687bbd5821a7556670595841 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Tue, 30 Jul 2019 21:58:35 +0200 Subject: [PATCH 2/2] Fix formatting issues. --- nasl/nasl_scanner_glue.c | 4 ++-- src/attack.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nasl/nasl_scanner_glue.c b/nasl/nasl_scanner_glue.c index 97fa0f851..0b0fbc4ea 100644 --- a/nasl/nasl_scanner_glue.c +++ b/nasl/nasl_scanner_glue.c @@ -466,9 +466,9 @@ script_add_preference (lex_ctxt *lexic) "Argument error in the call to script_add_preference()\n"); return FAKE_CELL; } - for (i = 0; i < nvti_pref_len (script_infos->nvti); i ++) + for (i = 0; i < nvti_pref_len (script_infos->nvti); i++) { - if (!strcmp (name, nvtpref_name (nvti_pref (script_infos->nvti,i)))) + if (!strcmp (name, nvtpref_name (nvti_pref (script_infos->nvti, i)))) { nasl_perror (lexic, "Preference '%s' already exists\n", name); return FAKE_CELL; diff --git a/src/attack.c b/src/attack.c index a8c9eaf77..881cbb81b 100644 --- a/src/attack.c +++ b/src/attack.c @@ -275,7 +275,8 @@ launch_plugin (struct scan_globals *globals, struct scheduler_plugin *plugin, if (network_scan_status (globals) == NSS_BUSY) network_scan = TRUE; - if (prefs_get_bool ("safe_checks") && !nvti_category_is_safe (nvti_category (nvti))) + if (prefs_get_bool ("safe_checks") + && !nvti_category_is_safe (nvti_category (nvti))) { if (prefs_get_bool ("log_whole_attack")) {