WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 17 months ago

#14207 assigned defect (bug)

streams.php, POMO_FileReader $length parameter of fread

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

Description

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 3 years ago.
streams.php (4.7 KB) - added by bueltge 3 years ago.
14207.patch (416 bytes) - added by SergeyBiryukov 2 years ago.
14207.2.patch (891 bytes) - added by SergeyBiryukov 17 months ago.

Download all attachments as: .zip

Change History (15)

comment:1 nacin3 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 bueltge3 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().

bueltge3 years ago

bueltge3 years ago

comment:3 nacin3 years ago

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

comment:4 SergeyBiryukov2 years ago

  • Keywords reporter-feedback added

What are the steps to reproduce this?

comment:5 Bueltge2 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

SergeyBiryukov2 years ago

comment:6 SergeyBiryukov2 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 bueltge2 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 SergeyBiryukov22 months ago

  • Keywords reporter-feedback removed

comment:10 nacin17 months ago

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

SergeyBiryukov17 months ago

comment:11 SergeyBiryukov17 months 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.

Note: See TracTickets for help on using tickets.