Make WordPress Core

Changeset 41467 for branches/3.9


Ignore:
Timestamp:
09/19/2017 02:43:13 PM (8 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.9 branch.

Location:
branches/3.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9

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

    r40732 r41467  
    639639            continue;
    640640
     641        if ( 0 !== validate_file( $info['name'] ) ) {
     642            return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
     643        }
     644
    641645        $uncompressed_size += $info['size'];
    642646
     
    791795        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
    792796            continue;
     797
     798        if ( 0 !== validate_file( $file['filename'] ) ) {
     799            return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
     800        }
    793801
    794802        if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
Note: See TracChangeset for help on using the changeset viewer.