Skip to content

Commit

Permalink
Add early length check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Schwartz committed Oct 5, 2020
1 parent 5f16090 commit 2b2558d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shadowsocks/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var zeroNonce [12]byte
// function will panic.
func Pack(dst, plaintext []byte, cipher shadowaead.Cipher) ([]byte, error) {
saltSize := cipher.SaltSize()
if len(dst) < saltSize {
return nil, io.ErrShortBuffer
}
salt := dst[:saltSize]
if err := RandomSaltGenerator.GetSalt(salt); err != nil {
return nil, err
Expand Down

0 comments on commit 2b2558d

Please sign in to comment.