From 695d1e9038f5882390ac59a5fae74e502c1b0c9a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 24 Jul 2014 11:04:48 +0200 Subject: [PATCH] Only fclose($fp) when $mode & NET_SFTP_LOCAL_FILE. --- phpseclib/Net/SFTP.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index d7151b58..1f6db1c0 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1871,7 +1871,9 @@ class Net_SFTP extends Net_SSH2 $subtemp = $offset + $sent; $packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp); if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) { - fclose($fp); + if ($mode & NET_SFTP_LOCAL_FILE) { + fclose($fp); + } return false; } $sent+= strlen($temp);