diff --git a/INSTALL.md b/INSTALL.md index 4d8f7f91..71d7bff5 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,6 +18,7 @@ General build environment: Specific development libraries: * libcjson >= 1.7.14 (util) +* libcurl >= 7.74.0 (openvasd) * libglib >= 2.42 (all) * libgio >= 2.42 (util) * zlib >= 1.2.8 (util) @@ -45,6 +46,7 @@ Install prerequisites on Debian GNU/Linux 'Bullseye' 11: cmake \ pkg-config \ libcjson-dev \ + libcurl4-openssl-dev \ libglib2.0-dev \ libgpgme-dev \ libgnutls28-dev \ diff --git a/openvasd/openvasd.c b/openvasd/openvasd.c index 69315fc0..271c467f 100644 --- a/openvasd/openvasd.c +++ b/openvasd/openvasd.c @@ -234,26 +234,26 @@ init_openvasd_stringstream (openvasd_stringstream *s) s->ptr = g_malloc0 (s->len + 1); } -/** @brief Reinitialize the string struct to hold the response +/** @brief Free the string struct to hold the response * - * @param s The string struct to be initialized + * @param s The string struct to be freed */ -static void -reset_openvasd_stringstream (openvasd_stringstream *s) +void +free_openvasd_stringstream (openvasd_stringstream *s) { - g_free (s->ptr); - init_openvasd_stringstream (s); + if (s) + g_free (s->ptr); } -/** @brief Free the string struct to hold the response +/** @brief Reinitialize the string struct to hold the response * - * @param s The string struct to be initialized + * @param s The string struct to be reset */ -static void -free_openvasd_stringstream (openvasd_stringstream *s) +void +reset_openvasd_stringstream (openvasd_stringstream *s) { - if (s) - g_free (s->ptr); + free_openvasd_stringstream (s); + init_openvasd_stringstream (s); } /** @brief Call back function to stored the response. @@ -529,7 +529,7 @@ openvasd_get_version (openvasd_connector_t *conn) curl_slist_free_all (customheader); response->code = RESP_CODE_ERR; response->body = err; - free_openvasd_stringstream (resp.ptr); + free_openvasd_stringstream (&resp); return response; } @@ -538,7 +538,7 @@ openvasd_get_version (openvasd_connector_t *conn) if (response->code != RESP_CODE_ERR) response->body = g_strdup (resp.ptr); - free_openvasd_stringstream (resp.ptr); + free_openvasd_stringstream (&resp); return response; } diff --git a/openvasd/openvasd.h b/openvasd/openvasd.h index adda1ab7..31c34f05 100644 --- a/openvasd/openvasd.h +++ b/openvasd/openvasd.h @@ -287,6 +287,12 @@ typedef struct openvasd_string void init_openvasd_stringstream (openvasd_stringstream *s); +void +reset_openvasd_stringstream (openvasd_stringstream *s); + +void +free_openvasd_stringstream (openvasd_stringstream *s); + openvasd_curlm_t * openvasd_curlm_handler_new (void); diff --git a/openvasd/vtparser.c b/openvasd/vtparser.c index 52b46779..2007598e 100644 --- a/openvasd/vtparser.c +++ b/openvasd/vtparser.c @@ -226,7 +226,7 @@ parse_references (nvti_t *nvt, cJSON *vt_obj) } else { - g_warning ("%s: REF missing type attribute", __func__); + g_warning ("%s: REF missing class attribute", __func__); continue; } } @@ -346,6 +346,7 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) cJSON_Delete (vt_obj); return NULL; } + g_free (error_message); nvt = nvti_new (); @@ -356,7 +357,6 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) { g_warning ("%s: VT missing OID", __func__); cJSON_Delete (vt_obj); - g_free (error_message); nvti_free (nvt); return NULL; } @@ -368,7 +368,6 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) { g_warning ("%s: VT missing NAME", __func__); cJSON_Delete (vt_obj); - g_free (error_message); nvti_free (nvt); return NULL; } @@ -380,7 +379,6 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) { g_warning ("%s: VT missing FAMILY", __func__); cJSON_Delete (vt_obj); - g_free (error_message); nvti_free (nvt); return NULL; } @@ -392,7 +390,6 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) { g_warning ("%s: VT missing CATEGORY", __func__); cJSON_Delete (vt_obj); - g_free (error_message); nvti_free (nvt); return NULL; } @@ -404,6 +401,5 @@ openvasd_parse_vt (gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event) parse_references (nvt, vt_obj); add_preferences_to_nvt (nvt, vt_obj); cJSON_Delete (vt_obj); - g_free (error_message); return nvt; }