diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index e5cd3134fd..2f9ad96c57 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -638,6 +638,10 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) { if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory continue; + if ( 0 !== validate_file( $info['name'] ) ) { + return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); + } + $uncompressed_size += $info['size']; if ( '/' == substr($info['name'], -1) ) // directory @@ -791,6 +795,10 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) { if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files continue; + if ( 0 !== validate_file( $file['filename'] ) ) { + return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] ); + } + if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); }