Skip to content

Commit 99b01fb

Browse files
committed
ws fix
1 parent 84fcc44 commit 99b01fb

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

ext/session/mod_files.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,27 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC)
136136

137137
data->lastkey = estrdup(key);
138138

139-
/* O_NOFOLLOW to prevent us from following evil symlinks */
139+
/* O_NOFOLLOW to prevent us from following evil symlinks */
140140
#ifdef O_NOFOLLOW
141-
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY | O_NOFOLLOW, data->filemode);
141+
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY | O_NOFOLLOW, data->filemode);
142142
#else
143-
/* Check to make sure that the opened file is not outside of allowable dirs.
144-
This is not 100% safe but it's hard to do something better without O_NOFOLLOW */
145-
if(PG(open_basedir) && lstat(buf, &sbuf) == 0 && S_ISLNK(sbuf.st_mode) && php_check_open_basedir(buf TSRMLS_CC)) {
146-
return;
147-
}
148-
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY, data->filemode);
143+
/* Check to make sure that the opened file is not outside of allowable dirs.
144+
This is not 100% safe but it's hard to do something better without O_NOFOLLOW */
145+
if(PG(open_basedir) && lstat(buf, &sbuf) == 0 && S_ISLNK(sbuf.st_mode) && php_check_open_basedir(buf TSRMLS_CC)) {
146+
return;
147+
}
148+
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY, data->filemode);
149149
#endif
150150

151151
if (data->fd != -1) {
152152
#ifndef PHP_WIN32
153-
/* check that this session file was created by us or root – we
154-
don't want to end up accepting the sessions of another webapp */
155-
if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) {
153+
/* check that this session file was created by us or root – we
154+
don't want to end up accepting the sessions of another webapp */
155+
if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) {
156156
close(data->fd);
157157
data->fd = -1;
158158
return;
159-
}
159+
}
160160
#endif
161161
flock(data->fd, LOCK_EX);
162162

0 commit comments

Comments
 (0)