[wp-trac] [WordPress Trac] #35755: wp_tempnam produces filenames longer than 255 characters

WordPress Trac noreply at wordpress.org
Fri Feb 5 10:46:45 UTC 2016


#35755: wp_tempnam produces filenames longer than 255 characters
----------------------------+-----------------------------
 Reporter:  doems           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 '''Summary'''
 Since the maximal filename length of the most filesystems out there is
 255, the function should try to avoid filenames longer than 255
 characters.

 '''Reproduce'''
 If the passed-in $filename parameter is longer than 245 characters
 (WordPress appends a string which has 10 characters), PHP will fail on the
 following line:
 [https://github.com/WordPress/WordPress/blob/6995ec613e5f113cedea4f0481b9030f79fabc0a
 /wp-admin/includes/file.php#L183].

 '''Fix'''
 {{{#!php
 <?php
 if ( strlen( $filename ) > 245 ) {
     $filename = substr( $filename, 0, 244);
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35755>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list