Make WordPress Core

Changeset 41463 for branches/4.3


Ignore:
Timestamp:
09/19/2017 02:41:23 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.3 branch.

Location:
branches/4.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3

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

    r40728 r41463  
    607607            continue;
    608608
     609        if ( 0 !== validate_file( $info['name'] ) ) {
     610            return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
     611        }
     612
    609613        $uncompressed_size += $info['size'];
    610614
     
    763767        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
    764768            continue;
     769
     770        if ( 0 !== validate_file( $file['filename'] ) ) {
     771            return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
     772        }
    765773
    766774        if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
Note: See TracChangeset for help on using the changeset viewer.