Skip to content

Commit 73a64e9

Browse files
committed
Initialize outputs passed to realpath
On error, realpath does not populate the output array. Zero out the arrays before passing them to realpath. Signed-off-by: Seth Moore <[email protected]>
1 parent d166ff0 commit 73a64e9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

psw/urts/linux/urts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extern "C" sgx_status_t __sgx_create_enclave_ex(const char *file_name,
9292
return SGX_ERROR_ENCLAVE_FILE_ACCESS;
9393
}
9494
se_file_t file = {NULL, 0, false};
95-
char resolved_path[PATH_MAX];
95+
char resolved_path[PATH_MAX] = {0};
9696
file.name = realpath(file_name, resolved_path);
9797
file.name_len = (uint32_t)strnlen_s(resolved_path, PATH_MAX);
9898

psw/urts/linux/urts_internal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ extern "C" sgx_status_t sgx_create_le(const char* file_name, const char* prd_css
5959
return SGX_ERROR_ENCLAVE_FILE_ACCESS;
6060
}
6161
se_file_t file = {NULL, 0, false};
62-
char resolved_path[PATH_MAX];
62+
char resolved_path[PATH_MAX] = {0};
6363
file.name = realpath(file_name, resolved_path);
6464
file.name_len = (uint32_t)strlen(resolved_path);
6565

66-
char css_real_path[PATH_MAX];
66+
char css_real_path[PATH_MAX] = {0};
6767

6868
le_prd_css_file_t prd_css_file = {NULL, false};
6969
prd_css_file.prd_css_name = realpath(prd_css_file_name, css_real_path);

0 commit comments

Comments
 (0)