client fix potential crash if we receive a short packet

This commit is contained in:
Nicola Murino 2021-03-10 12:26:09 +01:00
parent 5b7da38a9c
commit 23462f6cd7
1 changed files with 4 additions and 1 deletions

View File

@ -273,7 +273,10 @@ func (c *Client) recvVersion() error {
return &unexpectedPacketErr{sshFxpVersion, typ}
}
version, data := unmarshalUint32(data)
version, data, err := unmarshalUint32Safe(data)
if err != nil {
return err
}
if version != sftpProtocolVersion {
return &unexpectedVersionErr{sftpProtocolVersion, version}
}