From 216cdeedea484b9aadbb44018e92b6011b88d577 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 27 Jun 2008 20:14:50 +0000 Subject: [PATCH] Check fopen return value. Props Otto42 and pishmishy. fixes #4448 git-svn-id: http://svn.automattic.com/wordpress/trunk@8208 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 94fe97853..fa16d7db7 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"; }