From c7afa63283eca99b7f8df0cb53a9e1fd2091007e Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 27 Jun 2008 20:14:50 +0000 Subject: [PATCH] Check fopen return value. Props Otto42 and pishmishy. fixes #4448 git-svn-id: https://develop.svn.wordpress.org/trunk@8208 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/theme-editor.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index 94fe97853a..fa16d7db76 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -43,10 +43,15 @@ case 'update': $newcontent = stripslashes($_POST['newcontent']); $theme = urlencode($theme); if (is_writeable($real_file)) { + //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable $f = fopen($real_file, 'w+'); - fwrite($f, $newcontent); - fclose($f); - $location = "theme-editor.php?file=$file&theme=$theme&a=te"; + if ($f !== FALSE) { + fwrite($f, $newcontent); + fclose($f); + $location = "theme-editor.php?file=$file&theme=$theme&a=te"; + } else { + $location = "theme-editor.php?file=$file&theme=$theme"; + } } else { $location = "theme-editor.php?file=$file&theme=$theme"; }