Skip to content

Commit

Permalink
fix #650 OS_chmod uses read or write access.
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Dec 1, 2020
1 parent 7c1b59a commit 4cd6531
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/os/portable/os-impl-posix-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
struct stat st;
int fd;

/* Open file to avoid filename race potential */
/* Open file to avoid filename race potential */
fd = open(local_path, O_RDONLY);
if (fd < 0)
{
return OS_ERROR;
fd = open(local_path, O_WRONLY);
if (fd < 0)
{
return OS_ERROR;
}
}

/*
Expand Down

0 comments on commit 4cd6531

Please sign in to comment.