Skip to content

Commit

Permalink
Merge pull request #1421 from greenbone/mergify/bp/gvmd-21.04/pr-1419
Browse files Browse the repository at this point in the history
circle ci using buster images and various memory handling changes (bp #1417, #1419)
  • Loading branch information
timopollmeier authored Feb 10, 2021
2 parents 7bb9cab + 160cb2e commit b989692
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 48 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
command: clang-format -i -style=file src/gmp.h src/gmp_base.h src/gmp_delete.h src/gmp_get.h src/gmp_tickets.h src/gmpd.h src/iterator.h src/manage_utils.h src/sql.h src/types.h src/utils.h && git diff --exit-code
test_units:
docker:
- image: greenbone/build-env-gvm-master-debian-stretch-gcc-postgresql
- image: greenbone/build-env-gvm-master-debian-buster-gcc-postgresql
steps:
- run:
working_directory: ~/gvm-libs
Expand All @@ -26,7 +26,7 @@ jobs:
command: mkdir build && cd build/ && cmake -DBACKEND=POSTGRESQL -DCMAKE_BUILD_TYPE=Release -DENABLE_COVERAGE=1 .. && make && make tests && CTEST_OUTPUT_ON_FAILURE=1 make test && lcov --directory . --capture --output-file coverage.info && genhtml -o coverage coverage.info
build_postgresql_debug:
docker:
- image: greenbone/build-env-gvm-master-debian-stretch-gcc-postgresql
- image: greenbone/build-env-gvm-master-debian-buster-gcc-postgresql
steps:
- run:
working_directory: ~/gvm-libs
Expand All @@ -42,7 +42,7 @@ jobs:
command: mkdir build && cd build/ && cmake -DBACKEND=POSTGRESQL -DCMAKE_BUILD_TYPE=Debug .. && make install
build_postgresql_release:
docker:
- image: greenbone/build-env-gvm-master-debian-stretch-gcc-postgresql
- image: greenbone/build-env-gvm-master-debian-buster-gcc-postgresql
steps:
- run:
working_directory: ~/gvm-libs
Expand All @@ -58,7 +58,7 @@ jobs:
command: mkdir build && cd build/ && cmake -DBACKEND=POSTGRESQL -DCMAKE_BUILD_TYPE=Release .. && make install
build_postgresql_debug_clang:
docker:
- image: greenbone/build-env-gvm-master-debian-stretch-clang-postgresql
- image: greenbone/build-env-gvm-master-debian-buster-clang-postgresql
steps:
- run:
working_directory: ~/gvm-libs
Expand All @@ -74,7 +74,7 @@ jobs:
command: mkdir build && cd build/ && cmake -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="-Wno-ignored-attributes" -DBACKEND=POSTGRESQL -DCMAKE_BUILD_TYPE=Debug .. && make install
scan_build_postgresql_debug:
docker:
- image: greenbone/build-env-gvm-master-debian-stretch-clang-postgresql
- image: greenbone/build-env-gvm-master-debian-buster-clang-postgresql
steps:
- run:
working_directory: ~/gvm-libs
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Delete report format dirs last when deleting a user [#1368](https://github.com/greenbone/gvmd/pull/1368)
- Fix sorting in get_aggregates and its documentation [#1375](https://github.com/greenbone/gvmd/pull/1375)
- Improve "Failed to find..." messages [#1395](https://github.com/greenbone/gvmd/pull/1395)
- Memory handling in various occasions [#1417](https://github.com/greenbone/gvmd/pull/1417)

### Removed
- Remove DROP from vulns creation [#1281](http://github.com/greenbone/gvmd/pull/1281)
Expand Down
41 changes: 21 additions & 20 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10434,21 +10434,23 @@ buffer_aggregate_xml (GString *xml, iterator_t* aggregate, const gchar* type,
iso_time (&mean));
}
else
g_string_append_printf (xml,
"<stats column=\"%s\">"
"<min>%g</min>"
"<max>%g</max>"
"<mean>%g</mean>"
"<sum>%g</sum>"
"<c_sum>%g</c_sum>"
"</stats>",
data_column,
aggregate_iterator_min (aggregate, index),
aggregate_iterator_max (aggregate, index),
aggregate_iterator_mean (aggregate, index),
aggregate_iterator_sum (aggregate, index),
subgroup_column
? *subgroup_c_sum : c_sum);
{
g_string_append_printf (xml,
"<stats column=\"%s\">"
"<min>%g</min>"
"<max>%g</max>"
"<mean>%g</mean>"
"<sum>%g</sum>"
"<c_sum>%g</c_sum>"
"</stats>",
data_column,
aggregate_iterator_min (aggregate, index),
aggregate_iterator_max (aggregate, index),
aggregate_iterator_mean (aggregate, index),
aggregate_iterator_sum (aggregate, index),
subgroup_column && subgroup_c_sum
? *subgroup_c_sum : c_sum);
}
}

for (index = 0; index < text_columns->len; index++)
Expand Down Expand Up @@ -16952,9 +16954,9 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
report_t running_report;
char *owner, *observers;
int target_in_trash, scanner_in_trash;
int holes = 0, infos = 0, logs, warnings = 0;
int holes = 0, infos = 0, logs = 0, warnings = 0;
int holes_2 = 0, infos_2 = 0, warnings_2 = 0;
int false_positives, task_scanner_type;
int false_positives = 0, task_scanner_type;
int target_available, config_available;
int scanner_available;
double severity = 0, severity_2 = 0;
Expand Down Expand Up @@ -22026,12 +22028,11 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,

if (create_task_data->groups->len)
{
int fail;
gchar *fail_group_id;

switch ((fail = set_task_groups (create_task_data->task,
switch (set_task_groups (create_task_data->task,
create_task_data->groups,
&fail_group_id)))
&fail_group_id))
{
case 0:
break;
Expand Down
20 changes: 13 additions & 7 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -6501,10 +6501,13 @@ manage_run_wizard (const gchar *wizard_name,

if (g_regex_match_simple (regex, pair->value, 0, 0) == 0)
{
*command_error
= g_strdup_printf ("Value '%s' is not valid for"
" parameter '%s'.",
pair->value, name);
if (command_error)
{
*command_error
= g_strdup_printf ("Value '%s' is not valid for"
" parameter '%s'.",
pair->value, name);
}
free_entity (entity);
g_string_free (params_xml, TRUE);
return 6;
Expand All @@ -6515,9 +6518,12 @@ manage_run_wizard (const gchar *wizard_name,

if (optional == 0 && param_found == 0)
{
*command_error = g_strdup_printf ("Mandatory wizard param '%s'"
" missing",
name);
if (command_error)
{
*command_error = g_strdup_printf ("Mandatory wizard param '%s'"
" missing",
name);
}
free_entity (entity);
return 6;
}
Expand Down
30 changes: 23 additions & 7 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -5260,7 +5260,7 @@ init_aggregate_iterator (iterator_t* iterator, const char *type,
int index;
order_column = NULL;
for (index = 0;
index < data_columns->len && order_column == NULL;
data_columns && index < data_columns->len && order_column == NULL;
index++)
{
gchar *column = g_array_index (data_columns, gchar*, index);
Expand All @@ -5285,7 +5285,7 @@ init_aggregate_iterator (iterator_t* iterator, const char *type,
}

for (index = 0;
index < text_columns->len && order_column == NULL;
text_columns && index < text_columns->len && order_column == NULL;
index++)
{
gchar *column = g_array_index (text_columns, gchar*, index);
Expand Down Expand Up @@ -10188,7 +10188,6 @@ send_to_sourcefire (const char *ip, const char *port, const char *pkcs12_64,

/* Parent on success. Wait for child, and check result. */

g_free (command);

while (waitpid (pid, &status, 0) < 0)
{
Expand All @@ -10211,6 +10210,7 @@ send_to_sourcefire (const char *ip, const char *port, const char *pkcs12_64,
g_warning ("%s: and chdir failed",
__func__);
g_free (previous_dir);
g_free (command);
return -1;
}
if (WIFEXITED (status))
Expand All @@ -10227,6 +10227,7 @@ send_to_sourcefire (const char *ip, const char *port, const char *pkcs12_64,
g_warning ("%s: and chdir failed",
__func__);
g_free (previous_dir);
g_free (command);
return -1;
}
else
Expand All @@ -10238,11 +10239,12 @@ send_to_sourcefire (const char *ip, const char *port, const char *pkcs12_64,
g_warning ("%s: and chdir failed",
__func__);
g_free (previous_dir);
g_free (command);
return -1;
}

/* Child succeeded, continue to process result. */

g_free (command);
break;
}
}
Expand Down Expand Up @@ -10648,7 +10650,8 @@ buffer_vfire_call_input (gchar *key, gchar *value, GString *buffer)
param); \
else \
{ \
*message = g_strdup ("Mandatory " G_STRINGIFY(param) " missing."); \
if (message) \
*message = g_strdup ("Mandatory " G_STRINGIFY(param) " missing."); \
g_warning ("%s: Missing " G_STRINGIFY(param) ".", __func__); \
g_string_free (config_xml, TRUE); \
return -1; \
Expand Down Expand Up @@ -10799,7 +10802,7 @@ send_to_vfire (const char *base_url, const char *client_id,
g_warning ("%s: Alert script exited with status %d",
__func__, exit_status);
g_message ("%s: stderr: %s",
__func__, *message);
__func__, message ? *message: "");
ret = -5;
}

Expand Down Expand Up @@ -11857,6 +11860,7 @@ report_content_for_alert (alert_t alert, report_t report, task_t task,
break;
case 1: /* Too few rows in result of query. */
case -1:
g_free(alert_filter_get);
return -1;
break;
default: /* Programming error. */
Expand Down Expand Up @@ -11887,6 +11891,7 @@ report_content_for_alert (alert_t alert, report_t report, task_t task,
__func__, format_uuid,
alert_method_name (alert_method (alert)));
g_free (format_uuid);
g_free (alert_filter_get);
return -2;
}
g_free (format_uuid);
Expand Down Expand Up @@ -25150,6 +25155,10 @@ add_port (GTree *ports, iterator_t *results)
*old_severity = *severity;
g_free (severity);
}
else
{
g_free (severity);
}
}

/**
Expand Down Expand Up @@ -27009,6 +27018,12 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
task_status_t run_status;

/* Init some vars to prevent warnings from older compilers. */
max_results = -1;
levels = NULL;
zone = NULL;
delta_states = NULL;
min_qod = NULL;
search_phrase = NULL;
total_result_count = filtered_result_count = 0;
orig_filtered_result_count = 0;
orig_f_false_positives = orig_f_warnings = orig_f_logs = orig_f_infos = 0;
Expand Down Expand Up @@ -51700,7 +51715,6 @@ modify_user (const gchar * user_id, gchar **name, const gchar *new_name,
user_name = sql_string ("SELECT name FROM users WHERE id = %llu",
user);
errstr = gvm_validate_password (password, user_name);
g_free (user_name);
if (errstr)
{
g_warning ("new password for '%s' rejected: %s", user_name, errstr);
Expand All @@ -51709,8 +51723,10 @@ modify_user (const gchar * user_id, gchar **name, const gchar *new_name,
else
g_free (errstr);
sql_rollback ();
g_free (user_name);
return -1;
}
g_free (user_name);
}

/* Check hosts. */
Expand Down
1 change: 0 additions & 1 deletion src/manage_sql_port_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,6 @@ create_port_list_internal (int check_access, const char *id, const char *name,
array_free (ranges);
if (ret)
{
g_free (quoted_name);
sql_rollback ();
return ret;
}
Expand Down
14 changes: 9 additions & 5 deletions src/manage_sql_report_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -3474,7 +3474,6 @@ run_report_format_script (gchar *report_format_id,

/* Parent on success. Wait for child, and check result. */

g_free (command);

while (waitpid (pid, &status, 0) < 0)
{
Expand Down Expand Up @@ -3513,6 +3512,7 @@ run_report_format_script (gchar *report_format_id,
g_warning ("%s: and chdir failed",
__func__);
g_free (previous_dir);
g_free (command);
return -1;
}
else
Expand All @@ -3523,9 +3523,11 @@ run_report_format_script (gchar *report_format_id,
if (chdir (previous_dir))
g_warning ("%s: and chdir failed",
__func__);
g_free (command);
g_free (previous_dir);
return -1;
}
g_free (command);

/* Child succeeded, continue to process result. */

Expand Down Expand Up @@ -3842,13 +3844,15 @@ apply_report_format (gchar *report_format_id,
while (temp_dirs)
{
gvm_file_remove_recurse (temp_dirs->data);
g_free (temp_dirs->data);
temp_dirs = g_list_remove (temp_dirs, temp_dirs->data);
gpointer data = temp_dirs->data;
temp_dirs = g_list_remove (temp_dirs, data);
g_free (data);
}
while (temp_files)
{
g_free (temp_files->data);
temp_files = g_list_remove (temp_files, temp_files->data);
gpointer data = temp_files->data;
temp_files = g_list_remove (temp_files, data);
g_free (data);
}
g_free (files_xml);
g_hash_table_destroy (subreports);
Expand Down
5 changes: 2 additions & 3 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ split_xml_file (gchar *path, const gchar *size, const gchar *tail)
WIFEXITED (ret) ? WEXITSTATUS (ret) : 0,
command);
g_free (command);
g_free (previous_dir);

if (chdir (previous_dir))
g_warning ("%s: and failed to chdir back", __func__);
g_free (previous_dir);

return NULL;
}
Expand Down Expand Up @@ -3788,7 +3788,7 @@ oval_files_free ()
int index;

index = 0;
while (index < oval_files->len)
while (oval_files && index < oval_files->len)
{
gchar **pair;

Expand Down Expand Up @@ -3923,7 +3923,6 @@ update_scap_ovaldefs (int private)
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
{
g_warning ("No user data directory '%s' found.", oval_dir);
g_free (oval_dir);
g_error_free (error);
}
else
Expand Down

0 comments on commit b989692

Please sign in to comment.