Make WordPress Core

Changeset 41469 for branches/3.7/src


Ignore:
Timestamp:
09/19/2017 02:46:55 PM (9 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 3.7 branch.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

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

    r40734 r41469  
    610610                        continue;
    611611
     612                if ( 0 !== validate_file( $info['name'] ) ) {
     613                        return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
     614                }
     615
    612616                $uncompressed_size += $info['size'];
    613617
    … …  
    762766                if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
    763767                        continue;
     768
     769                if ( 0 !== validate_file( $file['filename'] ) ) {
     770                        return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
     771                }
    764772
    765773                if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
Note: See TracChangeset for help on using the changeset viewer.