diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 6bc1e93d..80f26fff 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -918,6 +918,9 @@ class File_ASN1 { } $value = new Math_BigInteger($value); $value = $value->toBytes(true); + if (!strlen($value)) { + $value = chr(0); + } } break; case FILE_ASN1_TYPE_UTC_TIME: diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 1b08f57f..27787b74 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1648,6 +1648,7 @@ class Net_SFTP extends Net_SSH2 { } break; case NET_SFTP_STATUS: + // could, in theory, return false if !strlen($content) but we'll hold off for the time being $this->_logError($response); break 2; default: @@ -1691,6 +1692,7 @@ class Net_SFTP extends Net_SSH2 { return false; } + // if $content isn't set that means a file was written to if (isset($content)) { return $content; } diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 4d3f6cf6..01ebee8c 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -37,8 +37,8 @@ /** * Include Net_SSH2 */ -if (!class_exists('Net_SSH2')) { - require_once('../Net/SSH2.php'); +if (!class_exists('Net_SFTP')) { + require_once('Net/SFTP.php'); } /** @@ -256,7 +256,7 @@ class Net_SFTP_Stream { //} $result = $this->sftp->get($this->path, false, $this->pos, $count); - if ($result === false) { + if (empty($result)) { $this->eof = true; return false; } @@ -659,4 +659,4 @@ class Net_SFTP_Stream { } } -stream_wrapper_register('sftp', 'Net_SFTP_Stream'); \ No newline at end of file +stream_wrapper_register('sftp', 'Net_SFTP_Stream');