WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/24/2017 03:04:35 AM (3 years ago)
Author:
dd32
Message:

Filesystem: Use a more unique filename in wp_tempnam() and get_filesystem_method().
Using a filename which was generated from time() could cause two processes to try to use the same filename, causing unexpected behaviour.

Props jrchamp, bikecrazyy.
Fixes #42265.

File:
1 edited

Legend:

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

    r42217 r42224  
    625625
    626626    if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) {
    627         $filename = time();
     627        $filename = uniqid();
    628628    }
    629629
     
    14671467    if ( ! $method ) {
    14681468
    1469         $temp_file_name = $context . 'temp-write-test-' . time();
     1469        $temp_file_name = $context . 'temp-write-test-' . str_replace( '.', '-', uniqid( '', true ) );
    14701470        $temp_handle = @fopen($temp_file_name, 'w');
    14711471        if ( $temp_handle ) {
Note: See TracChangeset for help on using the changeset viewer.