Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btcec: Avoid panic in FieldVal.SetByteSlice #1178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
btcec: Avoid panic in FieldVal.SetByteSlice
When called with a value larger than 32 bytes.
  • Loading branch information
stevenroose committed May 24, 2018
commit de8a49d40af7eb33d8c335d9263af95702f4bf6b
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