From ff37b87c2d4b3ad4b570148dc0c973dc4f5d2c71 Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Mon, 6 Jul 2026 11:44:16 +0200 Subject: [PATCH] More detailed error handling for function "stop_task (...)". --- src/gmp.c | 36 ++++++++++++++++++++++++++++++++++++ src/manage.c | 8 ++++---- src/manage_sql_filters.c | 2 ++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index 4131b593e..b4c2a4ce3 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -29773,6 +29773,42 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context, return; } break; + case 10: /* Internal error */ + g_warning ("Internal error while sending command"); + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("stop_task", + "Internal error while sending command")); + log_event_fail ("task", "Task", + stop_task_data->task_id, + "stopped"); + break; + case 20: /* Sending command timed out */ + g_warning ("Sending command timed out"); + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("stop_task", + "Sending command timed out")); + log_event_fail ("task", "Task", + stop_task_data->task_id, + "stopped"); + break; + case 30: /* Reading command response timed out */ + g_warning ("Reading command response timed out"); + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("stop_task", + "Reading command response timed out")); + log_event_fail ("task", "Task", + stop_task_data->task_id, + "stopped"); + break; + case 40: /* Problem deleting scan from scanner */ + g_warning ("Problem deleting scan from scanner"); + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("stop_task", + "Problem deleting scan from scanner")); + log_event_fail ("task", "Task", + stop_task_data->task_id, + "stopped"); + break; case 99: SEND_TO_CLIENT_OR_FAIL (XML_ERROR_SYNTAX ("stop_task", diff --git a/src/manage.c b/src/manage.c index 5bb839b05..8dcb448b6 100644 --- a/src/manage.c +++ b/src/manage.c @@ -2334,6 +2334,8 @@ stop_osp_task (task_t task) if (!connection) goto end_stop_osp; ret = osp_delete_scan (connection, scan_id); + if (ret) + ret = 4; osp_connection_close (connection); end_stop_osp: @@ -2347,9 +2349,7 @@ stop_osp_task (task_t task) } current_scanner_task = previous_task; global_current_report = previous_report; - if (ret) - return -1; - return 0; + return ret; } /** @@ -2414,7 +2414,7 @@ stop_task (const char *task_id) if (scanner_type (task_scanner (task)) == SCANNER_TYPE_OPENVAS || scanner_type (task_scanner (task)) == SCANNER_TYPE_OSP_SENSOR) - return stop_osp_task (task); + return stop_osp_task (task) * 10; #if ENABLE_OPENVASD if (scanner_type (task_scanner (task)) == SCANNER_TYPE_OPENVASD diff --git a/src/manage_sql_filters.c b/src/manage_sql_filters.c index 5f1a3ab88..3d6260395 100644 --- a/src/manage_sql_filters.c +++ b/src/manage_sql_filters.c @@ -866,6 +866,8 @@ columns_select_column_single (column_t *select_columns, *type = KEYWORD_TYPE_UNKNOWN; if (select_columns == NULL) return NULL; + if (filter_column == NULL) + return NULL; columns = select_columns; while ((*columns).select) {