Skip to content

At least one byte needs to be present for successful C / b decodes #1970

@kiropowered

Description

@kiropowered

Hello,
I am actually using SFTP class to log into AWS Tranfer Family in a long running process that need to upload files.
After a while AWS seems like to disconnect the user and phpseclib does not detect it.

In order to check if the connection is still open I call isConnected method but it always return true and then after I try to upload a file it leads to the following error;
Connection closed prematurely

I tried a different approach using ping() and now the error is :
At least one byte needs to be present for successful C / b decodes

This is the logs:
`-> NET_SSH2_MSG_REQUEST_FAILURE (since last: 0.0001, network: 0s)

<- NET_SSH2_MSG_DEBUG (since last: 0, network: 0s)
00000000 00:00:00:00:4e:53:46:54:50:3a:20:6b:65:79:20:6f ....NSFTP: key o
00000010 70:74:69:6f:6e:73:3a:20:61:67:65:6e:74:2d:66:6f ptions: agent-fo
00000020 72:77:61:72:64:69:6e:67:20:70:6f:72:74:2d:66:6f rwarding port-fo
00000030 72:77:61:72:64:69:6e:67:20:70:74:79:20:75:73:65 rwarding pty use
00000040 72:2d:72:63:20:78:31:31:2d:66:6f:72:77:61:72:64 r-rc x11-forward
00000050 69:6e:67:00:00:00:00 ing....

<- NET_SSH2_MSG_DEBUG (since last: 0, network: 0s)
00000000 00:00:00:00:4e:53:46:54:50:3a:20:6b:65:79:20:6f ....NSFTP: key o
00000010 70:74:69:6f:6e:73:3a:20:61:67:65:6e:74:2d:66:6f ptions: agent-fo
00000020 72:77:61:72:64:69:6e:67:20:70:6f:72:74:2d:66:6f rwarding port-fo
00000030 72:77:61:72:64:69:6e:67:20:70:74:79:20:75:73:65 rwarding pty use
00000040 72:2d:72:63:20:78:31:31:2d:66:6f:72:77:61:72:64 r-rc x11-forward
00000050 69:6e:67:00:00:00:00 ing....

<- NET_SSH2_MSG_UNIMPLEMENTED (since last: 0.004, network: 0.004s)
00000000 00:00:00:06 ....

At least one byte needs to be present for successful C / b decodes
0 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2664): phpseclib3\Common\Functions\Strings::unpackSSH2('C', false)
1 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2334): phpseclib3\Net\SSH2->privatekey_login('xxxxx', Object(phpseclib3\Crypt\RSA\PrivateKey))
2 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2279): phpseclib3\Net\SSH2->login_helper('xxxxx', Object(phpseclib3\Crypt\RSA\PrivateKey))
3 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2191): phpseclib3\Net\SSH2->sublogin('xxxxx', Object(phpseclib3\Crypt\RSA\PrivateKey))
4 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(3386): phpseclib3\Net\SSH2->login('xxxxx', Object(phpseclib3\Crypt\RSA\PrivateKey))
5 /var/www/html/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(3368): phpseclib3\Net\SSH2->reconnect()`


I am using the version 3.0.33, tried also 3.0.34, but got the same errors

Other logs I got :
SSH_MSG_GLOBAL_REQUEST: hostkeys-00@openssh.com
SSH_MSG_DEBUG: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
SSH_MSG_DEBUG: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
SSH_MSG_GLOBAL_REQUEST: hostkeys-00@openssh.com
SSH_MSG_DEBUG: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
SSH_MSG_DEBUG: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
SSH_MSG_DISCONNECT: NET_SSH2_DISCONNECT_PROTOCOL_ERROR
data packet referred to nonexistent channel 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions