Skip to content

Commit

Permalink
btcec: Avoid panic in FieldVal.SetByteSlice
Browse files Browse the repository at this point in the history
When called with a value larger than 32 bytes.
  • Loading branch information
stevenroose committed May 24, 2018
1 parent bc09449 commit de8a49d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions btcec/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ func (f *fieldVal) SetBytes(b *[32]byte) *fieldVal {
// The field value is returned to support chaining. This enables syntax like:
// f := new(fieldVal).SetByteSlice(byteSlice)
func (f *fieldVal) SetByteSlice(b []byte) *fieldVal {
if len(b) > 32 {
b = b[:32]
}

var b32 [32]byte
for i := 0; i < len(b); i++ {
if i < 32 {
Expand Down

0 comments on commit de8a49d

Please sign in to comment.