Make WordPress Core

Changeset 41457


Ignore:
Timestamp:
09/19/2017 02:35:09 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r41364 r41457  
    667667            continue;
    668668
     669        if ( 0 !== validate_file( $info['name'] ) ) {
     670            return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
     671        }
     672
    669673        $uncompressed_size += $info['size'];
    670674
     
    826830        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
    827831            continue;
     832
     833        if ( 0 !== validate_file( $file['filename'] ) ) {
     834            return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
     835        }
    828836
    829837        if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
Note: See TracChangeset for help on using the changeset viewer.