Make WordPress Core

Changeset 41458 for branches/4.8


Ignore:
Timestamp:
09/19/2017 02:36:21 PM (7 years ago)
Author:
johnbillion
Message:

Filesystem API: Ensure filenames are valid before attempting to unzip them to ensure malformed file paths don't cause issues.

Merges [41457] to the 4.8 branch.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-admin/includes/file.php

    r40723 r41458  
    648648            continue;
    649649
     650        if ( 0 !== validate_file( $info['name'] ) ) {
     651            return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
     652        }
     653
    650654        $uncompressed_size += $info['size'];
    651655
     
    807811        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
    808812            continue;
     813
     814        if ( 0 !== validate_file( $file['filename'] ) ) {
     815            return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
     816        }
    809817
    810818        if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
Note: See TracChangeset for help on using the changeset viewer.