Skip to content

Commit

Permalink
Merge pull request #159 from yechun1/replace_appdata
Browse files Browse the repository at this point in the history
Replace the environment variable of %APPDATA%
  • Loading branch information
StevenPontsler authored Jan 21, 2021
2 parents 4c80118 + a8f4b77 commit 643c695
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/os/eventlog/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@ static EFI_STATUS get_the_system_log_file_name(log_file_type file, UINTN file_si
if (FALSE == g_log_file_table[SYSTEM_LOG_AR_FILE].name_initialized) {
efi_status = preferences_get_string_ascii(g_log_file_table[SYSTEM_LOG_AR_FILE].ini_entry_name, guid, SYSTEM_LOG_FILE_NAME_MAX_LEN, g_log_file_table[SYSTEM_LOG_AR_FILE].file_name);
if (EFI_SUCCESS == efi_status) {
// Overwrite environment variables
// Find the environment variable control chars
p_env_start = strchr(g_log_file_table[SYSTEM_LOG_AR_FILE].file_name, ENVIRONMENT_VARIABLE_CHAR_START);
if (NULL != p_env_start)
{
p_env_start++; // start + 1 cause we have to skip the ENVIRONMENT_VARIABLE_CHAR_START char
p_env_stop = strchr(p_env_start, ENVIRONMENT_VARIABLE_CHAR_STOP);
if (NULL != p_env_stop) {
// Replace the environment variable with the real value
environment_variable[0] = 0; // Initialize the environemt variable string as empty
strncat_s(environment_variable, ENVIRONMENT_VARIABLE_MAX_LEN, p_env_start, p_env_stop - p_env_start);
if (NULL != (p_env_variable_path = getenv(environment_variable))) {
snprintf(temp_file_name, SYSTEM_LOG_FILE_NAME_MAX_LEN, "%s", p_env_variable_path);
}
p_env_stop++; // stop + 1 cause we have to skip the ENVIRONMENT_VARIABLE_CHAR_STOP char
strcat_s(temp_file_name, SYSTEM_LOG_FILE_NAME_MAX_LEN, p_env_stop);
// Store the proper file name
strncpy_s(g_log_file_table[SYSTEM_LOG_AR_FILE].file_name, SYSTEM_LOG_FILE_NAME_MAX_LEN, temp_file_name, SYSTEM_LOG_FILE_NAME_MAX_LEN);
}
}
g_log_file_table[SYSTEM_LOG_AR_FILE].name_initialized = TRUE;
}
}
Expand Down

0 comments on commit 643c695

Please sign in to comment.