Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tee-supplicant: Enforce paths bound limits #366

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tee-supplicant/src/tee_supplicant.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ static void set_ta_path(void)
char *new_path = NULL;
size_t n = 0;
const char *path = supplicant_params.ta_load_path;
int path_len = -1;

if (!path)
path = TEEC_LOAD_PATH;
Expand Down Expand Up @@ -733,10 +734,17 @@ static void set_ta_path(void)
if (!supplicant_params.ta_load_path) {
char full_path[PATH_MAX] = { 0 };

snprintf(full_path, PATH_MAX, "%s/%s", new_path,
supplicant_params.ta_dir);
path_len = snprintf(full_path, PATH_MAX, "%s/%s", new_path,
supplicant_params.ta_dir);
if (path_len < 0 || path_len >= PATH_MAX)
goto err_path;
TanelDettenborn marked this conversation as resolved.
Show resolved Hide resolved

ta_path[n++] = strdup(full_path);
} else {
path_len = strnlen(new_path, PATH_MAX);
if (path_len == PATH_MAX)
goto err_path;

ta_path[n++] = strdup(new_path);
}

Expand All @@ -749,6 +757,10 @@ static void set_ta_path(void)
err:
EMSG("out of memory");
exit(EXIT_FAILURE);

err_path:
EMSG("Path exceeds maximum path length");
exit(EXIT_FAILURE);
}

/*
Expand Down