mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
add a recoverer where appropriate
I have never seen this, but a malformed packet can easily crash pkg/sftp
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user