Skip to content

Commit 289cb0f

Browse files
weltlingsmalyshev
authored andcommitted
Fixed bug #76459 windows linkinfo lacks openbasedir check
1 parent 3462efa commit 289cb0f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ext/standard/link_win32.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,31 @@ PHP_FUNCTION(readlink)
8787
PHP_FUNCTION(linkinfo)
8888
{
8989
char *link;
90-
int link_len;
90+
char *dirname;
91+
int link_len, dir_len;
9192
struct stat sb;
9293
int ret;
9394

9495
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) {
9596
return;
9697
}
9798

99+
dirname = estrndup(link, link_len);
100+
dir_len = php_dirname(dirname, link_len);
101+
102+
if (php_check_open_basedir(dirname TSRMLS_CC)) {
103+
efree(dirname);
104+
RETURN_FALSE;
105+
}
106+
98107
ret = VCWD_STAT(link, &sb);
99108
if (ret == -1) {
100109
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
110+
efree(dirname);
101111
RETURN_LONG(-1L);
102112
}
103113

114+
efree(dirname);
104115
RETURN_LONG((long) sb.st_dev);
105116
}
106117
/* }}} */

0 commit comments

Comments
 (0)