Skip to content

Commit

Permalink
Fixed bug #76459 windows linkinfo lacks openbasedir check
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling authored and smalyshev committed Jul 16, 2018
1 parent 3462efa commit 289cb0f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ext/standard/link_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,31 @@ PHP_FUNCTION(readlink)
PHP_FUNCTION(linkinfo)
{
char *link;
int link_len;
char *dirname;
int link_len, dir_len;
struct stat sb;
int ret;

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

dirname = estrndup(link, link_len);
dir_len = php_dirname(dirname, link_len);

if (php_check_open_basedir(dirname TSRMLS_CC)) {
efree(dirname);
RETURN_FALSE;
}

ret = VCWD_STAT(link, &sb);
if (ret == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
efree(dirname);
RETURN_LONG(-1L);
}

efree(dirname);
RETURN_LONG((long) sb.st_dev);
}
/* }}} */
Expand Down

0 comments on commit 289cb0f

Please sign in to comment.