Skip to content
Open
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
48 changes: 43 additions & 5 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29754,17 +29754,17 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
{
switch (stop_task (stop_task_data->task_id))
{
case 0: /* Stopped. */
case STOP_TASK_OK_STOPPED: /* Stopped. */
SEND_TO_CLIENT_OR_FAIL (XML_OK ("stop_task"));
log_event ("task", "Task", stop_task_data->task_id,
"stopped");
break;
case 1: /* Stop requested. */
case STOP_TASK_OK_STOP_REQUESTED: /* Stop requested. */
SEND_TO_CLIENT_OR_FAIL (XML_OK_REQUESTED ("stop_task"));
log_event ("task", "Task", stop_task_data->task_id,
"requested to stop");
break;
case 3: /* Find failed. */
case STOP_TASK_NOT_FOUND: /* Find failed. */
if (send_find_error_to_client ("stop_task", "task",
stop_task_data->task_id,
gmp_parser))
Expand All @@ -29773,7 +29773,45 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
return;
}
break;
case 99:
case STOP_TASK_SEND_INTERNAL_ERROR: /* 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 STOP_TASK_SEND_TIMEOUT: /* 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 STOP_TASK_RECEIVE_TIMEOUT:
/* 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 STOP_TASK_DELETE_FAILED:
/* 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 STOP_TASK_PERMISSION_DENIED:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("stop_task",
"Permission denied"));
Expand All @@ -29783,7 +29821,7 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
break;
default: /* Programming error. */
assert (0);
case -1:
case STOP_TASK_INTERNAL_ERROR:
/* Some other error occurred. */
/** @todo Should respond with internal error. */
abort ();
Expand Down
33 changes: 28 additions & 5 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ start_task (const char *task_id, char **report_id)
*
* @param[in] task The task.
*
* @return 0 on success, else -1.
* @return 0 on success, else an other error code.
*/
static int
stop_osp_task (task_t task)
Expand Down Expand Up @@ -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:
Expand All @@ -2347,9 +2349,30 @@ stop_osp_task (task_t task)
}
current_scanner_task = previous_task;
global_current_report = previous_report;
if (ret)
return -1;
return 0;
return ret;
}

/**
* @brief Map the return code of stop_osp_task to an modify
* task return code.
*
* @param[in] rc The stop_osp_task (..) return code.
*
* @return The corresponding modify task return code.
*/
static stop_task_return_t
map_stop_osp_task_rc_to_modify_task_rc (int rc)
{
switch (rc)
{
case -1: return STOP_TASK_INTERNAL_ERROR;
case 0: return STOP_TASK_OK_STOPPED;
case 1: return STOP_TASK_SEND_INTERNAL_ERROR;
case 2: return STOP_TASK_SEND_TIMEOUT;
case 3: return STOP_TASK_RECEIVE_TIMEOUT;
case 4: return STOP_TASK_DELETE_FAILED;
default: return STOP_TASK_INTERNAL_ERROR;
}
}

/**
Expand Down Expand Up @@ -2414,7 +2437,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 map_stop_osp_task_rc_to_modify_task_rc (stop_osp_task (task));

#if ENABLE_OPENVASD
if (scanner_type (task_scanner (task)) == SCANNER_TYPE_OPENVASD
Expand Down
12 changes: 12 additions & 0 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ typedef enum {
} modify_task_return_t;


typedef enum {
STOP_TASK_OK_STOPPED = 0,
STOP_TASK_OK_STOP_REQUESTED = 1,
STOP_TASK_NOT_FOUND = 3,
STOP_TASK_SEND_INTERNAL_ERROR = 10,
STOP_TASK_SEND_TIMEOUT = 11,
STOP_TASK_RECEIVE_TIMEOUT = 12,
STOP_TASK_DELETE_FAILED = 13,
STOP_TASK_PERMISSION_DENIED = 99,
STOP_TASK_INTERNAL_ERROR = -1
} stop_task_return_t;

/**
* @brief Name value pair.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/manage_sql_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +869 to +870

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unrelated to the error handler improvements.

columns = select_columns;
while ((*columns).select)
{
Expand Down
Loading