diff --git a/src/manage.c b/src/manage.c index 74770fb1f..413f39e3f 100644 --- a/src/manage.c +++ b/src/manage.c @@ -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; } @@ -8123,7 +8123,7 @@ 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); @@ -8131,7 +8131,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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } diff --git a/src/manage_sql_nvts.c b/src/manage_sql_nvts.c index 30f5a0de2..3ae7ea5b4 100644 --- a/src/manage_sql_nvts.c +++ b/src/manage_sql_nvts.c @@ -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. * @@ -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__); @@ -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) { @@ -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; @@ -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); @@ -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; }