Index: src/wp-admin/includes/class-wp-filesystem-direct.php
===================================================================
--- src/wp-admin/includes/class-wp-filesystem-direct.php	(revision 25270)
+++ src/wp-admin/includes/class-wp-filesystem-direct.php	(working copy)
@@ -59,12 +59,20 @@
 	 * @param int $mode (optional) The file permissions as octal number, usually 0644.
 	 * @return bool False upon failure.
 	 */
-	function put_contents($file, $contents, $mode = false ) {
-		if ( ! ($fp = @fopen($file, 'w')) )
+	function put_contents( $file, $contents, $mode = false ) {
+		$fp = @fopen( $file, 'wb' );
+		if ( ! $fp )
 			return false;
-		@fwrite($fp, $contents);
-		@fclose($fp);
-		$this->chmod($file, $mode);
+
+		$bytes_written = fwrite( $fp, $contents );
+
+		fclose( $fp );
+
+		if ( false === $bytes_written || $bytes_written != strlen( $contents ) )
+			return false;
+
+		$this->chmod( $file, $mode );
+
 		return true;
 	}
 	/**
Index: src/wp-admin/includes/class-wp-filesystem-ftpext.php
===================================================================
--- src/wp-admin/includes/class-wp-filesystem-ftpext.php	(revision 25270)
+++ src/wp-admin/includes/class-wp-filesystem-ftpext.php	(working copy)
@@ -88,17 +88,14 @@
 		return true;
 	}
 
-	function get_contents($file, $type = '', $resumepos = 0 ) {
-		if ( empty($type) )
-			$type = FTP_BINARY;
-
+	function get_contents( $file ) {
 		$tempfile = wp_tempnam($file);
 		$temp = fopen($tempfile, 'w+');
 
 		if ( ! $temp )
 			return false;
 
-		if ( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) )
+		if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) )
 			return false;
 
 		fseek($temp, 0); //Skip back to the start of the file being written to
@@ -117,13 +114,19 @@
 
 	function put_contents($file, $contents, $mode = false ) {
 		$tempfile = wp_tempnam($file);
-		$temp = fopen($tempfile, 'w+');
+		$temp = fopen( $tempfile, 'wb+' );
 		if ( ! $temp )
 			return false;
 
-		fwrite($temp, $contents);
-		fseek($temp, 0); //Skip back to the start of the file being written to
+		$bytes_written = fwrite( $temp, $contents );
+		if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
+			fclose( $temp );
+			unlink( $tempfile );
+			return false;
+		}
 
+		fseek( $temp, 0 ); // Skip back to the start of the file being written to
+
 		$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
 		$ret = @ftp_fput($this->link, $file, $temp, $type);
 
@@ -187,7 +190,7 @@
 		if ( ! $overwrite && $this->exists($destination) )
 			return false;
 		$content = $this->get_contents($source);
-		if ( false === $content)
+		if ( false === $content )
 			return false;
 		return $this->put_contents($destination, $content, $mode);
 	}
Index: src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
===================================================================
--- src/wp-admin/includes/class-wp-filesystem-ftpsockets.php	(revision 25274)
+++ src/wp-admin/includes/class-wp-filesystem-ftpsockets.php	(working copy)
@@ -75,19 +75,19 @@
 			return false;
 		}
 
-		$this->ftp->SetType(FTP_AUTOASCII);
+		// ASCII mode will auto-convert line endings
+		$this->ftp->SetType(FTP_BINARY);
 		$this->ftp->Passive(true);
 		$this->ftp->setTimeout(FS_TIMEOUT);
 		return true;
 	}
 
-	function get_contents($file, $type = '', $resumepos = 0) {
+	function get_contents( $file ) {
 		if ( ! $this->exists($file) )
 			return false;
 
-		if ( empty($type) )
-			$type = FTP_AUTOASCII;
-		$this->ftp->SetType($type);
+		// Always transfer in Binary, otherwise the ftp class will normalize line endings
+		$this->ftp->SetType( FTP_BINARY );
 
 		$temp = wp_tempnam( $file );
 
@@ -122,12 +122,18 @@
 			return false;
 		}
 
-		fwrite($temphandle, $contents);
-		fseek($temphandle, 0); //Skip back to the start of the file being written to
+		$bytes_written = fwrite( $temphandle, $contents );
+		if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
+			fclose( $temphandle );
+			unlink( $temp );
+			return false;
+		}
 
-		$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
-		$this->ftp->SetType($type);
+		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
 
+		// Always transfer in Binary, otherwise the ftp class will normalize line endings
+		$this->ftp->SetType( FTP_BINARY );
+
 		$ret = $this->ftp->fput($file, $temphandle);
 
 		fclose($temphandle);
Index: src/wp-admin/includes/class-wp-filesystem-ssh2.php
===================================================================
--- src/wp-admin/includes/class-wp-filesystem-ssh2.php	(revision 25270)
+++ src/wp-admin/includes/class-wp-filesystem-ssh2.php	(working copy)
@@ -150,7 +150,7 @@
 		return false;
 	}
 
-	function get_contents($file, $type = '', $resumepos = 0 ) {
+	function get_contents( $file ) {
 		$file = ltrim($file, '/');
 		return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
 	}
@@ -164,9 +164,12 @@
 		$file = ltrim($file, '/');
 		$ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
 
+		if ( false === $ret || $ret != strlen( $contents ) )
+			return false;
+
 		$this->chmod($file, $mode);
 
-		return false !== $ret;
+		return true;
 	}
 
 	function cwd() {
