WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 8 months ago

Last modified 8 months ago

#14207 closed defect (bug) (worksforme)

streams.php, POMO_FileReader $length parameter of fread

Reported by: bueltge Owned by: nbachiyski
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: I18N Keywords: has-patch reporter-feedback
Focuses: Cc:

Description (last modified by SergeyBiryukov)

the fread function run with an error, when you have the length-paramter ist 0. This is possible on use WP in local engines and intranet.
Small changes on the function: read in class POMO_FileReader

	function read($bytes) {
		if ( isset($bytes) && ( 0 > $bytes ) )
			return fread($this->_f, $bytes);
		else
			return;
	}

Attachments (4)

streams.patch (637 bytes) - added by bueltge 5 years ago.
streams.php (4.7 KB) - added by bueltge 5 years ago.
14207.patch (416 bytes) - added by SergeyBiryukov 4 years ago.
14207.2.patch (891 bytes) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 @nacin5 years ago

  • Component changed from Administration to i18n
  • Severity changed from critical to major

Without speaking at all to the validity of the patch, checking for empty() would be much simpler.

Lowering priority a bit as fread() with zero length fires only a warning, not a fatal, and I'm still not sure of the steps to reproduce an instance where 0 is requested.

comment:2 @bueltge5 years ago

the warning is an problem when you work with WP_DEBUG true; its not possible to use the backend. Yes, you can change this to empty().

@bueltge5 years ago

@bueltge5 years ago

comment:3 @nacin5 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Owner set to nbachiyski
  • Status changed from new to assigned

comment:4 @SergeyBiryukov4 years ago

  • Keywords reporter-feedback added

What are the steps to reproduce this?

comment:5 @Bueltge4 years ago

"the fread function run with an error, when you have the length-paramter ist 0. This is possible on use WP in local engines and intranet"
when the blog in a landscape without internet-connection

@SergeyBiryukov4 years ago

comment:6 @SergeyBiryukov4 years ago

Still don't quite understand the connection between intranet and reading .mo files.

However I guess the condition in the patch should be inverted:

if ( !empty($bytes) )
	return fread($this->_f, $bytes);
else
	return false;

Uploaded new patch.

comment:7 @bueltge4 years ago

I have check this on my development-version and now works fine, no errors for fread. Thanks

	function read($bytes) {
		if ( !empty($bytes) )
			return fread($this->_f, $bytes);
		else
			return false;
	}

comment:9 @SergeyBiryukov4 years ago

  • Keywords reporter-feedback removed

comment:10 @nacin3 years ago

Perhaps the read() method should be avoided if ! $bytes?

@SergeyBiryukov3 years ago

comment:11 @SergeyBiryukov3 years ago

  • Keywords reporter-feedback added

read() method is only called for an arbitrary number of bytes in lines 160 and 169 of mo.php:
http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/pomo/mo.php#L160

14207.2.patch makes sure the values passed to read() are not zero.

I'm still not sure what are we trying to fix here though. I've checked a localized install without Internet access with WP_DEBUG on and didn't see any warnings.

comment:12 @chriscct78 months ago

  • Keywords dev-feedback added; reporter-feedback removed
  • Resolution set to worksforme
  • Status changed from assigned to closed

Seems this is an impossible scenario to generate. Closing as worksforme.

comment:13 @SergeyBiryukov8 months ago

  • Description modified (diff)
  • Keywords reporter-feedback added; dev-feedback removed
  • Milestone Future Release deleted

comment:14 @SergeyBiryukov8 months ago

  • Severity changed from major to normal
Note: See TracTickets for help on using tickets.