add precheck in a few more places

This commit is contained in:
terrafrost 2021-08-29 11:41:32 -05:00
parent 19e7737ead
commit 4102bbaccc

View File

@ -829,6 +829,10 @@ class Net_SFTP extends Net_SSH2
*/ */
function realpath($path) function realpath($path)
{ {
if (!$this->_precheck()) {
return false;
}
return $this->_realpath($path); return $this->_realpath($path);
} }
@ -1293,10 +1297,6 @@ class Net_SFTP extends Net_SSH2
*/ */
function size($filename) function size($filename)
{ {
if (!$this->_precheck()) {
return false;
}
$result = $this->stat($filename); $result = $this->stat($filename);
if ($result === false) { if ($result === false) {
return false; return false;
@ -2693,6 +2693,10 @@ SFTP v6 changes (from v5)
function file_exists($path) function file_exists($path)
{ {
if ($this->use_stat_cache) { if ($this->use_stat_cache) {
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path); $path = $this->_realpath($path);
$result = $this->_query_stat_cache($path); $result = $this->_query_stat_cache($path);
@ -2763,6 +2767,10 @@ SFTP v6 changes (from v5)
*/ */
function is_readable($path) function is_readable($path)
{ {
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path); $path = $this->_realpath($path);
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_READ, 0); $packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_READ, 0);
@ -2791,6 +2799,10 @@ SFTP v6 changes (from v5)
*/ */
function is_writable($path) function is_writable($path)
{ {
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path); $path = $this->_realpath($path);
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_WRITE, 0); $packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_WRITE, 0);
@ -2971,6 +2983,10 @@ SFTP v6 changes (from v5)
*/ */
function _get_xstat_cache_prop($path, $prop, $type) function _get_xstat_cache_prop($path, $prop, $type)
{ {
if (!$this->_precheck()) {
return false;
}
if ($this->use_stat_cache) { if ($this->use_stat_cache) {
$path = $this->_realpath($path); $path = $this->_realpath($path);
@ -3000,6 +3016,10 @@ SFTP v6 changes (from v5)
*/ */
function rename($oldname, $newname) function rename($oldname, $newname)
{ {
if (!$this->_precheck()) {
return false;
}
// in SFTP v5+ // in SFTP v5+
// Add support for better control of the rename operation. // Add support for better control of the rename operation.
// so we'll just need to add \0\0\0\0 after // so we'll just need to add \0\0\0\0 after