don't expose underlying errors to clients

log them and return a generic failure

Fixes #896

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-06-28 22:08:16 +02:00
parent 101783ee86
commit 719f6077ab
3 changed files with 3 additions and 5 deletions

View File

@@ -1345,9 +1345,11 @@ func (c *BaseConnection) GetGenericError(err error) error {
}
if err != nil {
if e, ok := err.(*os.PathError); ok {
c.Log(logger.LevelError, "generic path error: %+v", e)
return fmt.Errorf("%w: %v %v", sftp.ErrSSHFxFailure, e.Op, e.Err.Error())
}
return fmt.Errorf("%w: %v", sftp.ErrSSHFxFailure, err.Error())
c.Log(logger.LevelError, "generic error: %+v", err)
return fmt.Errorf("%w: %v", sftp.ErrSSHFxFailure, ErrGenericFailure.Error())
}
return sftp.ErrSSHFxFailure
default: