Skip to content

Commit 0199b22

Browse files
ext/opcache: check mkstemp() return value right after the call (#8031)
Don't call fchmod(-1), which is not only wrong, but also clobbers errno and sets it to EBADF, breaking the following errno access for the log message.
1 parent 706398f commit 0199b22

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/opcache/zend_shared_alloc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ void zend_shared_alloc_create_lock(char *lockfile_path)
8383

8484
snprintf(lockfile_name, sizeof(lockfile_name), "%s/%sXXXXXX", lockfile_path, SEM_FILENAME_PREFIX);
8585
lock_file = mkstemp(lockfile_name);
86-
fchmod(lock_file, 0666);
87-
8886
if (lock_file == -1) {
8987
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to create lock file: %s (%d)", strerror(errno), errno);
9088
}
89+
90+
fchmod(lock_file, 0666);
91+
9192
val = fcntl(lock_file, F_GETFD, 0);
9293
val |= FD_CLOEXEC;
9394
fcntl(lock_file, F_SETFD, val);

0 commit comments

Comments
 (0)