mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-13 21:29:14 +00:00
git_futils: don't O_EXCL and O_TRUNC
`O_EXCL` and `O_TRUNC` are mutually exclusive flags to open(2); you can't truncate a file if you're asserting that it can't exist in the first place. Drop `O_TRUNC`.
This commit is contained in:
parent
33ea4aae37
commit
4a26915d34
@ -66,8 +66,8 @@ int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode
|
|||||||
|
|
||||||
int git_futils_creat_locked(const char *path, const mode_t mode)
|
int git_futils_creat_locked(const char *path, const mode_t mode)
|
||||||
{
|
{
|
||||||
int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC |
|
int fd = p_open(path, O_WRONLY | O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC,
|
||||||
O_EXCL | O_BINARY | O_CLOEXEC, mode);
|
mode);
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
int error = errno;
|
int error = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user