mirror of https://github.com/pkg/sftp.git
Make SSH_FXP_STATUS "message" field optional.
Cisco SSH 2.0 server doesn't fill out the "message" field, even though it returns valid status codes. This makes File.Read method error out without actually reading the file due to unmarshalStatus returning a "packet too short" error.
This commit is contained in:
parent
b4b1d297a4
commit
59640f4fcc
|
@ -1094,10 +1094,7 @@ func unmarshalStatus(id uint32, data []byte) error {
|
|||
return &unexpectedIDErr{id, sid}
|
||||
}
|
||||
code, data := unmarshalUint32(data)
|
||||
msg, data, err := unmarshalStringSafe(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg, data, _ := unmarshalStringSafe(data)
|
||||
lang, _, _ := unmarshalStringSafe(data)
|
||||
return &StatusError{
|
||||
Code: code,
|
||||
|
|
|
@ -116,7 +116,9 @@ func TestUnmarshalStatus(t *testing.T) {
|
|||
desc: "missing error message and language tag",
|
||||
reqID: 1,
|
||||
status: idCode,
|
||||
want: errShortPacket,
|
||||
want: &StatusError{
|
||||
Code: ssh_FX_FAILURE,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "missing language tag",
|
||||
|
|
Loading…
Reference in New Issue