Skip to content

Commit

Permalink
Check result of realpath(3) for stdenv dir_open
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jul 10, 2024
1 parent 161310e commit 2f691b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rt/stdenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ void _std_env_dir_open(directory_t *dir, const uint8_t *path_ptr,
}

char resolved[PATH_MAX];
realpath(path, resolved);
if (realpath(path, resolved) == NULL) {
*status = errno_to_dir_open_status();
return;
}

const size_t resolvedsz = strlen(resolved);
size_t memsz = sizeof(ffi_uarray_t)*2 + resolvedsz;
Expand Down

0 comments on commit 2f691b8

Please sign in to comment.