Skip to content

Commit

Permalink
collectd.org/network: Check length of encrypted payload.
Browse files Browse the repository at this point in the history
Don't assume that there are at least two bytes in ciphertext.

Issue: #10
  • Loading branch information
octo committed Aug 28, 2015
1 parent 4a5b07d commit d33a039
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions network/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func decryptAES256(ciphertext []byte, lookup PasswordLookup) ([]byte, error) {
if lookup == nil {
return nil, errors.New("no PasswordLookup available")
}
if len(ciphertext) < 2 {
return nil, errors.New("buffer too short")
}

buf := bytes.NewBuffer(ciphertext)
userLen := int(binary.BigEndian.Uint16(buf.Next(2)))
Expand Down

0 comments on commit d33a039

Please sign in to comment.