add a recoverer where appropriate

I have never seen this, but a malformed packet can easily crash pkg/sftp
This commit is contained in:
Nicola Murino
2020-10-31 11:02:04 +01:00
parent fcfdd633f6
commit 950a5ad9ea
7 changed files with 73 additions and 6 deletions

View File

@@ -1846,3 +1846,28 @@ func TestSFTPSubSystem(t *testing.T) {
err = subsystemChannel.Close()
assert.NoError(t, err)
}
func TestRecoverer(t *testing.T) {
c := Configuration{}
c.AcceptInboundConnection(nil, nil)
connID := "connectionID"
connection := &Connection{
BaseConnection: common.NewBaseConnection(connID, common.ProtocolSFTP, dataprovider.User{}, nil),
}
c.handleSftpConnection(nil, connection)
sshCmd := sshCommand{
command: "cd",
connection: connection,
}
err := sshCmd.handle()
assert.EqualError(t, err, common.ErrGenericFailure.Error())
scpCmd := scpCommand{
sshCommand: sshCommand{
command: "scp",
connection: connection,
},
}
err = scpCmd.handle()
assert.EqualError(t, err, common.ErrGenericFailure.Error())
assert.Len(t, common.Connections.GetStats(), 0)
}