Skip to content

Commit

Permalink
open_basedir check for linkinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
rlerdorf committed Mar 25, 2012
1 parent 24a57ae commit 9007787
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ext/standard/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,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, "s", &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_LSTAT(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 9007787

Please sign in to comment.