diff options
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -3402,10 +3402,13 @@ int | |||
| 3402 | sys_open (const char * path, int oflag, int mode) | 3402 | sys_open (const char * path, int oflag, int mode) |
| 3403 | { | 3403 | { |
| 3404 | const char* mpath = map_w32_filename (path, NULL); | 3404 | const char* mpath = map_w32_filename (path, NULL); |
| 3405 | /* Try to open file without _O_CREAT, to be able to write to hidden | 3405 | int res = -1; |
| 3406 | and system files. Force all file handles to be | 3406 | |
| 3407 | non-inheritable. */ | 3407 | /* If possible, try to open file without _O_CREAT, to be able to |
| 3408 | int res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | 3408 | write to existing hidden and system files. Force all file |
| 3409 | handles to be non-inheritable. */ | ||
| 3410 | if ((oflag & (_O_CREAT | _O_EXCL)) != (_O_CREAT | _O_EXCL)) | ||
| 3411 | res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | ||
| 3409 | if (res < 0) | 3412 | if (res < 0) |
| 3410 | res = _open (mpath, oflag | _O_NOINHERIT, mode); | 3413 | res = _open (mpath, oflag | _O_NOINHERIT, mode); |
| 3411 | if (res >= 0 && res < MAXDESC) | 3414 | if (res >= 0 && res < MAXDESC) |