[wp-trac] [WordPress Trac] #44002: fread(): Length parameter must be greater than 0 - Happens on all updates to core, plugins, themes.

WordPress Trac noreply at wordpress.org
Tue May 8 06:32:17 UTC 2018


#44002: fread(): Length parameter must be greater than 0 - Happens on all updates
to core, plugins, themes.
-----------------------------+-----------------------------
 Reporter:  mopsyd           |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  4.9.5
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 I'm getting this error in my log every time updates are run. It occurs
 regardless of whether any plugins or non-wordpress issued themes are
 active. I am using Sentry on my live site to catch pretty much all errors,
 and this consistently turns up every time anything updates.

 As a test measure, I disabled app 3rd-party plugins and themes, and ran an
 update against an older version of the twentyfifteen theme as an isolated
 case. The issue still occurs in lieu of any other 3rd party modifications.


 {{{
 array(4) {
   ["type"]=>
   int(2)
   ["message"]=>
   string(48) "fread(): Length parameter must be greater than 0"
   ["file"]=>
   string(66) "/xxx/xxx/xxx/xxx/redacted.com/wp-admin/includes/class-
 pclzip.php"
   ["line"]=>
   int(4212)
 }
 }}}

 This appears to be a core bug with the updater. The issue has been
 consistent since at least 4.9.0, probably earlier.

 --------

 This component needs to be using fstat to check the size prior to
 attempting to read. Something like this:


 {{{
 $f = fopen('file', 'r+');
 $stat = fstat($f);
 $size = $stat['size'];

 if ( $size > 0 )
 {
     // The file is non-zero length and safe to read.
     $contents = fread( $f );
     // Carry on.
 } else {
     // Do not fread an empty file. Return, throw an exception, whatever's
 clever.
 }

 }}}

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


More information about the wp-trac mailing list