Make WordPress Core

Ticket #42619: 42619.diff

File 42619.diff, 1.1 KB (added by markjaquith, 4 years ago)

Check open_basedir before checking a directory's existence

  • src/wp-admin/includes/class-wp-automatic-updater.php

     
    5555                return apply_filters( 'automatic_updater_disabled', $disabled );
    5656        }
    5757
     58        public function is_allowed_dir( $dir ) {
     59                $open_basedir = ini_get('open_basedir');
     60
     61                if ( !$open_basedir ) {
     62                        return true;
     63                }
     64
     65                $open_basedir_dirs = explode(PATH_SEPARATOR, $open_basedir);
     66
     67                foreach ( $open_basedir_dirs as $basedir ) {
     68                        if ( strpos( $dir, $basedir ) === 0 ) {
     69                                return true;
     70                        }
     71                }
     72
     73                return false;
     74}
     75
    5876        /**
    5977         * Check for version control checkouts.
    6078         *
     
    101119                // Search all directories we've found for evidence of version control.
    102120                foreach ( $vcs_dirs as $vcs_dir ) {
    103121                        foreach ( $check_dirs as $check_dir ) {
    104                                 $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
     122                                $checkout = $this->is_allowed_dir( $check_dir ) && @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
    105123                                if ( $checkout ) {
    106124                                        break 2;
    107125                                }