pull/642/head
Darien Raymond 8 years ago
parent ceffb71e7b
commit 5bfab82c41
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -116,8 +116,7 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
return nil, newError("failed to write auth response").Base(err) return nil, newError("failed to write auth response").Base(err)
} }
} }
buffer.Clear() if err := buffer.Reset(buf.ReadFullFrom(reader, 4)); err != nil {
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil {
return nil, newError("failed to read request").Base(err) return nil, newError("failed to read request").Base(err)
} }
@ -192,24 +191,21 @@ func readUsernamePassword(reader io.Reader) (string, string, error) {
buffer := buf.NewLocal(512) buffer := buf.NewLocal(512)
defer buffer.Release() defer buffer.Release()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 2)); err != nil { if err := buffer.Reset(buf.ReadFullFrom(reader, 2)); err != nil {
return "", "", err return "", "", err
} }
nUsername := int(buffer.Byte(1)) nUsername := int(buffer.Byte(1))
buffer.Clear() if err := buffer.Reset(buf.ReadFullFrom(reader, nUsername)); err != nil {
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nUsername)); err != nil {
return "", "", err return "", "", err
} }
username := buffer.String() username := buffer.String()
buffer.Clear()
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 1)); err != nil { if err := buffer.Reset(buf.ReadFullFrom(reader, 1)); err != nil {
return "", "", err return "", "", err
} }
nPassword := int(buffer.Byte(0)) nPassword := int(buffer.Byte(0))
buffer.Clear() if err := buffer.Reset(buf.ReadFullFrom(reader, nPassword)); err != nil {
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, nPassword)); err != nil {
return "", "", err return "", "", err
} }
password := buffer.String() password := buffer.String()

Loading…
Cancel
Save