]> granicus.if.org Git - php/commitdiff
open_basedir check for linkinfo
authorRasmus Lerdorf <rasmus@php.net>
Sun, 25 Mar 2012 00:02:21 +0000 (05:32 +0530)
committerRasmus Lerdorf <rasmus@php.net>
Sun, 25 Mar 2012 00:02:21 +0000 (05:32 +0530)
ext/standard/link.c

index 9fa2524faf84f112c1123dd98a15e4b77b911df2..cb42408f6d760c54c8cf0838032ebbb5462bb94b 100644 (file)
@@ -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);
 }
 /* }}} */