Skip to content

Commit

Permalink
adjust to changes in gvm-libs/openvasd/
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Oct 21, 2024
1 parent 0e31fee commit 9343d96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -7183,7 +7183,7 @@ nvts_feed_info_internal_from_openvasd (const gchar *scanner_uuid,
ret = 0;
}

openvasd_response_free (resp);
openvasd_response_cleanup (resp);
openvasd_connector_free (&connector);
return ret;
}
Expand Down Expand Up @@ -8123,15 +8123,15 @@ prepare_openvasd_scan_for_resume (task_t task, const char *scan_id,
*error = g_strdup_printf ("Failed to stop old report: %ld",
response->code);
openvasd_connector_free (&connection);
openvasd_response_free(response);
openvasd_response_cleanup(response);
return -1;
}
response = openvasd_delete_scan (&connection);
if (response->code != 204)
{
*error = g_strdup_printf ("Failed to delete old report: %ld",
response->code);
openvasd_response_free(response);
openvasd_response_cleanup(response);
openvasd_connector_free (&connection);
return -1;
}
Expand All @@ -8149,7 +8149,7 @@ prepare_openvasd_scan_for_resume (task_t task, const char *scan_id,
{
*error = g_strdup_printf ("Failed to delete old report: %ld",
response->code);
openvasd_response_free(response);
openvasd_response_cleanup(response);
openvasd_connector_free (&connection);
return -1;
}
Expand All @@ -8167,7 +8167,7 @@ prepare_openvasd_scan_for_resume (task_t task, const char *scan_id,
{
*error = g_strdup_printf ("Failed to delete old report: %ld",
response->code);
openvasd_response_free(response);
openvasd_response_cleanup(response);
openvasd_connector_free (&connection);
return -1;
}
Expand Down Expand Up @@ -8493,7 +8493,7 @@ launch_openvasd_openvas_task (task_t task, target_t target, const char *scan_id,
g_slist_free_full (vts, (GDestroyNotify) openvasd_vt_single_free);
g_hash_table_destroy (scanner_options);
ret = response->code;
openvasd_response_free (response);
openvasd_response_cleanup (response);

return ret;
}
Expand Down Expand Up @@ -8688,7 +8688,7 @@ handle_openvasd_scan (task_t task, report_t report, const char *scan_id)
retry = connection_retry;
gvm_sleep (5);
}
openvasd_response_free (response);
openvasd_response_cleanup (response);
openvasd_connector_free(&connector);
return rc;
}
Expand Down
32 changes: 15 additions & 17 deletions src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -2245,8 +2245,7 @@ static int move_buffer_data(struct FILESTREAM *filestream){
/**
* @brief Update NVTs from Json response chunk by chunk
*
* @param[in] curl_hnd Curl handler to perform the request
* @param[in] res Struct containing the response chunks
* @param[in] conn Openvasd connector
* @param[in] scanner_feed_version Version of feed from scanner.
* @param[in] rebuild Whether we're rebuilding the tables.
*
Expand Down Expand Up @@ -2308,11 +2307,12 @@ update_nvts_from_json_vts (openvasd_connector_t *connector,
FILE *stream = NULL;
struct FILESTREAM *filestream;
nvti_t *nvti = NULL;
openvasd_curlm_t curl_hnd = NULL;
openvasd_stringstream res;
openvasd_curlm_t *curl_hnd = NULL;
openvasd_stringstream_t res;

init_openvasd_stringstream(&res);
resp = openvasd_get_vts_stream_init(connector, &curl_hnd, &res);
openvasd_stringstream_new (&res);
curl_hnd = openvasd_curlm_handler_new ();
resp = openvasd_get_vts_stream_init (connector, &curl_hnd, &res);
if (resp->code < 0)
{
g_warning ("%s: failed to get VTs", __func__);
Expand Down Expand Up @@ -2341,8 +2341,7 @@ update_nvts_from_json_vts (openvasd_connector_t *connector,
// First run for initial data in the stream
running = openvasd_get_vts_stream (curl_hnd);
fwrite (res.ptr, 1, res.len, stream);
g_free (res.ptr);
init_openvasd_stringstream(&res);
openvasd_stringstream_reset (&res);
int break_flag = 0;
while (running)
{
Expand All @@ -2356,8 +2355,7 @@ update_nvts_from_json_vts (openvasd_connector_t *connector,
{
move_buffer_data (filestream);
fwrite (res.ptr, 1, res.len, stream);
g_free (res.ptr);
init_openvasd_stringstream (&res);
openvasd_stringstream_reset (&res);
}

non_read_count = filestream->last_write - filestream->last_read;
Expand Down Expand Up @@ -2398,13 +2396,13 @@ update_nvts_from_json_vts (openvasd_connector_t *connector,
break;
}

gvm_json_pull_event_cleanup(&event);
gvm_json_pull_parser_cleanup(&parser);
fclose(stream);
gvm_json_pull_event_cleanup (&event);
gvm_json_pull_parser_cleanup (&parser);
fclose (stream);

g_free (res.ptr);
openvasd_curl_handler_close (&curl_hnd);
openvasd_response_free (resp);
openvasd_stringstream_cleanup (&res);
openvasd_curlm_handler_close (&curl_hnd);
openvasd_response_cleanup (resp);


batch_end (vt_refs_batch);
Expand Down Expand Up @@ -2973,7 +2971,7 @@ nvts_feed_info_internal_from_openvasd (const gchar *scanner_uuid,
ret = 0;
}

openvasd_response_free (resp);
openvasd_response_cleanup (resp);
openvasd_connector_free (&connector);
return ret;
}
Expand Down

0 comments on commit 9343d96

Please sign in to comment.