X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/76d0c1f61d5981603389e6267bf62636f34bef1f..e995052ef530b1eae2d0476ff519f7225bbb481d:/hotline/account.go diff --git a/hotline/account.go b/hotline/account.go index b041f3c..4c5a9b9 100644 --- a/hotline/account.go +++ b/hotline/account.go @@ -3,7 +3,9 @@ package hotline import ( "encoding/binary" "golang.org/x/crypto/bcrypt" + "io" "log" + "slices" ) const GuestAccount = "guest" // default account used when no login is provided for a connection @@ -30,13 +32,12 @@ func (a *Account) Read(p []byte) (n int, err error) { fieldCount := make([]byte, 2) binary.BigEndian.PutUint16(fieldCount, uint16(len(fields))) - p = append(p, fieldCount...) - + var fieldBytes []byte for _, field := range fields { - p = append(p, field.Payload()...) + fieldBytes = append(fieldBytes, field.Payload()...) } - return len(p), nil + return copy(p, slices.Concat(fieldCount, fieldBytes)), io.EOF } // hashAndSalt generates a password hash from a users obfuscated plaintext password