From 900778731c49611e1318e4d1839768eb46f26813 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sun, 25 Mar 2012 05:32:21 +0530 Subject: [PATCH] open_basedir check for linkinfo --- ext/standard/link.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/standard/link.c b/ext/standard/link.c index 9fa2524faf84f..cb42408f6d760 100644 --- a/ext/standard/link.c +++ b/ext/standard/link.c @@ -94,7 +94,8 @@ PHP_FUNCTION(readlink) PHP_FUNCTION(linkinfo) { char *link; - int link_len; + char *dirname; + int link_len, dir_len; struct stat sb; int ret; @@ -102,12 +103,22 @@ PHP_FUNCTION(linkinfo) 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); } /* }}} */