diff --git a/src/daemon/dlt-trace-load.conf b/src/daemon/dlt-trace-load.conf index 0834b98f4..30e3c2383 100644 --- a/src/daemon/dlt-trace-load.conf +++ b/src/daemon/dlt-trace-load.conf @@ -14,6 +14,7 @@ # SOFT_LIMIT and HARD_LIMIT are in byte/s # Warnings will be issues in the interval configured via DLT_USER_HARD_LIMIT_OVER_MSG_INTERVAL # the default for this is 1s +# The maximum for soft/hard limit is 2^32-1 (uint32 max) # # !!!! # Note: this file is space separated, and wildcards are not supported diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 1a59b6cbc..f3aa277b9 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -772,7 +772,7 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon, if (application->trace_load_settings == NULL) { DltTraceLoadSettings* pre_configured_trace_load_settings = NULL; int num_settings = 0; - DltReturnValue rv = dlt_daemon_find_preconfigured_trace_load_settings( + DltReturnValue find_trace_settings_return_value = dlt_daemon_find_preconfigured_trace_load_settings( daemon, application->apid, NULL /*load settings for all contexts*/, @@ -781,7 +781,7 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon, verbose); DltTraceLoadSettings *app_level = NULL; - if ((rv == DLT_RETURN_OK) && + if ((find_trace_settings_return_value == DLT_RETURN_OK) && (pre_configured_trace_load_settings != NULL) && (num_settings != 0)) { application->trace_load_settings = pre_configured_trace_load_settings; diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 5fc8255da..dc77b80d1 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -516,6 +516,11 @@ DltReturnValue dlt_init(void) pthread_rwlock_wrlock(&trace_load_rw_lock); trace_load_settings = malloc(sizeof(DltTraceLoadSettings)); + if (trace_load_settings == NULL) { + dlt_vlog(LOG_ERR, "Failed to allocate memory for trace load settings\n"); + dlt_user_init_state = INIT_UNITIALIZED; + return DLT_RETURN_ERROR; + } memset(trace_load_settings, 0, sizeof(DltTraceLoadSettings)); trace_load_settings[0].soft_limit = DLT_TRACE_LOAD_CLIENT_SOFT_LIMIT_DEFAULT; trace_load_settings[0].hard_limit = DLT_TRACE_LOAD_CLIENT_HARD_LIMIT_DEFAULT; @@ -4879,6 +4884,11 @@ DltReturnValue dlt_user_log_check_user_message(void) char msg[255]; trace_load_settings_alloc_size = sizeof(DltTraceLoadSettings) * trace_load_settings_user_messages_count; trace_load_settings = malloc(trace_load_settings_alloc_size); + if (trace_load_settings == NULL) { + pthread_rwlock_unlock(&trace_load_rw_lock); + dlt_log(LOG_ERR, "Failed to allocate memory for trace load settings\n"); + return DLT_RETURN_ERROR; + } memset(trace_load_settings, 0, trace_load_settings_alloc_size); for (i = 0; i < trace_load_settings_user_messages_count; i++) { strncpy(trace_load_settings[i].apid, dlt_user.appID, DLT_ID_SIZE); diff --git a/src/shared/dlt_config_file_parser.c b/src/shared/dlt_config_file_parser.c index a8a12f260..0b26de061 100644 --- a/src/shared/dlt_config_file_parser.c +++ b/src/shared/dlt_config_file_parser.c @@ -609,6 +609,10 @@ int trace_load_config_file_parser(DltDaemon *daemon, DltDaemonLocal *daemon_loca daemon->preconfigured_trace_load_settings_count = 0; } daemon->preconfigured_trace_load_settings = malloc(sizeof(DltTraceLoadSettings)); + if (daemon->preconfigured_trace_load_settings == NULL) { + dlt_log(LOG_CRIT, "Failed to allocate memory for trace load settings\n"); + return DLT_RETURN_ERROR; + } /* open configuration file */ filename = daemon_local->flags.lvalue[0] @@ -743,10 +747,10 @@ int trace_load_config_file_parser(DltDaemon *daemon, DltDaemonLocal *daemon_loca DltTraceLoadSettings *settings = NULL; int num_settings = 0; - DltReturnValue rv = dlt_daemon_find_preconfigured_trace_load_settings( + DltReturnValue find_trace_settings_return_value = dlt_daemon_find_preconfigured_trace_load_settings( daemon, app_id_value, ctx_id_value, &settings, &num_settings, 0); - if (rv != DLT_RETURN_OK || num_settings != 0) { + if (find_trace_settings_return_value != DLT_RETURN_OK || num_settings != 0) { dlt_vlog(LOG_WARNING, "App id '%.4s' is already configured, or an error occurred, skipping entry\n", app_id_value);