WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#44002 new defect (bug)

fread(): Length parameter must be greater than 0 - Happens on all updates to core, plugins, themes.

Reported by: mopsyd Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.5
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

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.
}

Change History (1)

#1 @subrataemfluence
7 weeks ago

Is this blocking your upgrades? I did not look into the log yet though.

Note: See TracTickets for help on using tickets.