From b5e80bc176a950b640c163abb91e4052bd604244 Mon Sep 17 00:00:00 2001 From: Andrey Grinenko Date: Sat, 11 Apr 2015 11:34:41 +0300 Subject: [PATCH] cosmetics --- phpseclib/Net/SFTP.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 909b7b20..55cf52c1 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1807,6 +1807,9 @@ class SFTP extends SSH2 $callback = false; switch (true) { case $mode & self::SOURCE_CALLBACK; + if (!is_callable($data)) { + throw new Exception('if you specify SOURCE_CALLBACK then $data should be callable'); + } $callback = $data; // do nothing break; @@ -1852,7 +1855,9 @@ class SFTP extends SSH2 while ($callback || $sent < $size) { if ($callback) { $temp = call_user_func($callback, $sftp_packet_size); - if (is_null($temp)) break; + if (is_null($temp)) { + break; + } } else { $temp = isset($fp) ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size); }