Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ext/session/mod_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ static void ps_files_open(ps_files *data, /* const */ zend_string *key)
data->last_key = zend_string_copy(key);

/* O_NOFOLLOW to prevent us from following evil symlinks */
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY | O_NOFOLLOW, data->filemode);
int flags = O_CREAT | O_RDWR | O_BINARY | O_NOFOLLOW;
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
data->fd = VCWD_OPEN_MODE(buf, flags, data->filemode);

if (data->fd != -1) {
#ifndef PHP_WIN32
Expand All @@ -198,7 +202,7 @@ static void ps_files_open(ps_files *data, /* const */ zend_string *key)
ret = flock(data->fd, LOCK_EX);
} while (ret == -1 && errno == EINTR);

#ifdef F_SETFD
#if defined(F_SETFD) && !defined(O_CLOEXEC)
# ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
# endif
Expand Down
Loading