]> granicus.if.org Git - php/commitdiff
Fixed bug #76459 windows linkinfo lacks openbasedir check
authorAnatol Belski <ab@php.net>
Tue, 3 Jul 2018 12:04:22 +0000 (14:04 +0200)
committerStanislav Malyshev <stas@php.net>
Mon, 16 Jul 2018 22:11:56 +0000 (15:11 -0700)
ext/standard/link_win32.c

index 13ee88dfade5906f3edfa4967b1223e562f7719b..0068a3edb1c6bac289637617d9d0b0e227be95ad 100644 (file)
@@ -87,6 +87,7 @@ PHP_FUNCTION(readlink)
 PHP_FUNCTION(linkinfo)
 {
        char *link;
+       char *dirname;
        size_t link_len;
        zend_stat_t sb;
        int ret;
@@ -95,12 +96,22 @@ PHP_FUNCTION(linkinfo)
                return;
        }
 
+       dirname = estrndup(link, link_len);
+       php_dirname(dirname, link_len);
+
+       if (php_check_open_basedir(dirname)) {
+               efree(dirname);
+               RETURN_FALSE;
+       }
+
        ret = VCWD_STAT(link, &sb);
        if (ret == -1) {
                php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
+               efree(dirname);
                RETURN_LONG(Z_L(-1));
        }
 
+       efree(dirname);
        RETURN_LONG((zend_long) sb.st_dev);
 }
 /* }}} */