Core and plugin update checking: make sure fsockopen() is available and check file resources with is_resource() -- both to prevent feof() infinite loops. Props xknown. fixes #5037

git-svn-id: https://develop.svn.wordpress.org/trunk@6151 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2007-09-22 00:08:50 +00:00
parent 856779888e
commit ccad303433
2 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,10 @@ add_action( 'admin_notices', 'update_nag', 3 );
function wp_update_plugins() {
global $wp_version;
if ( !function_exists('fsockopen') )
return false;
$plugins = get_plugins();
$active = get_option( 'active_plugins' );
$current = get_option( 'update_plugins' );
@ -83,7 +87,7 @@ function wp_update_plugins() {
$http_request .= $request;
$response = '';
if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) ) {
if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) {
fwrite($fs, $http_request);
while ( !feof($fs) )

View File

@ -3,7 +3,7 @@
// A simple set of functions to check our version 1.0 update service
function wp_version_check() {
if ( strpos($_SERVER['PHP_SELF'], 'install.php') !== false || defined('WP_INSTALLING') )
if ( !function_exists('fsockopen') || strpos($_SERVER['PHP_SELF'], 'install.php') !== false || defined('WP_INSTALLING') )
return;
global $wp_version;
@ -30,7 +30,7 @@ function wp_version_check() {
$http_request .= "\r\n";
$response = '';
if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) ) {
if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) {
fwrite( $fs, $http_request );
while ( !feof( $fs ) )
$response .= fgets( $fs, 1160 ); // One TCP-IP packet