Skip to content

Commit

Permalink
if open succeeds on a path with a trailing slash, it is a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
bmiddha committed Dec 19, 2024
1 parent fcd1118 commit 3b47ea1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/trace_exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,15 @@ int run_tracer(pid_t child_pid)
access_type = (flags & O_WRONLY || flags & O_RDWR) ? 'W' : 'R';
file_type = (flags & O_DIRECTORY) ? 'D' : 'F';

if (access_type == 'R' && isError != 0)
if (file_type = 'F' && access_type == 'R' && isError != 0)
{
int pathLen = strlen(path);
if (pathLen > 0 && path[pathLen - 1] == '/')
{
file_type = 'D';
}
}
else if (access_type == 'R' && isError != 0)
{
if (rVal == -EISDIR)
{
Expand Down

0 comments on commit 3b47ea1

Please sign in to comment.