Skip to content

Commit

Permalink
apply more sugestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Oct 17, 2024
1 parent 0e3a299 commit f088f04
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand Down
28 changes: 14 additions & 14 deletions openvasd/openvasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,26 +234,26 @@ init_openvasd_stringstream (openvasd_stringstream *s)
s->ptr = g_malloc0 (s->len + 1);

Check warning on line 234 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L233-L234

Added lines #L233 - L234 were not covered by tests
}

/** @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)

Check warning on line 242 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L242

Added line #L242 was not covered by tests
{
g_free (s->ptr);
init_openvasd_stringstream (s);
if (s)
g_free (s->ptr);

Check warning on line 245 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L245

Added line #L245 was not covered by tests
}

/** @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)

Check warning on line 253 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L253

Added line #L253 was not covered by tests
{
if (s)
g_free (s->ptr);
free_openvasd_stringstream (s);
init_openvasd_stringstream (s);

Check warning on line 256 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L255-L256

Added lines #L255 - L256 were not covered by tests
}

/** @brief Call back function to stored the response.
Expand Down Expand Up @@ -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;

Check warning on line 533 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L529-L533

Added lines #L529 - L533 were not covered by tests
}

Expand All @@ -538,7 +538,7 @@ openvasd_get_version (openvasd_connector_t *conn)
if (response->code != RESP_CODE_ERR)
response->body = g_strdup (resp.ptr);

Check warning on line 539 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L539

Added line #L539 was not covered by tests

free_openvasd_stringstream (resp.ptr);
free_openvasd_stringstream (&resp);
return response;

Check warning on line 542 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L541-L542

Added lines #L541 - L542 were not covered by tests
}

Expand Down
6 changes: 6 additions & 0 deletions openvasd/openvasd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 2 additions & 6 deletions openvasd/vtparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 230 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L229-L230

Added lines #L229 - L230 were not covered by tests
}
}
Expand Down Expand Up @@ -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;

Check warning on line 347 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L345-L347

Added lines #L345 - L347 were not covered by tests
}
g_free (error_message);

Check warning on line 349 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L349

Added line #L349 was not covered by tests

nvt = nvti_new ();

Check warning on line 351 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L351

Added line #L351 was not covered by tests

Expand All @@ -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;

Check warning on line 361 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L358-L361

Added lines #L358 - L361 were not covered by tests
}
Expand All @@ -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;

Check warning on line 372 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L369-L372

Added lines #L369 - L372 were not covered by tests
}
Expand All @@ -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;

Check warning on line 383 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L380-L383

Added lines #L380 - L383 were not covered by tests
}
Expand All @@ -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;

Check warning on line 394 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L391-L394

Added lines #L391 - L394 were not covered by tests
}
Expand All @@ -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;

Check warning on line 404 in openvasd/vtparser.c

View check run for this annotation

Codecov / codecov/patch

openvasd/vtparser.c#L401-L404

Added lines #L401 - L404 were not covered by tests
}

0 comments on commit f088f04

Please sign in to comment.