Skip to content

Commit

Permalink
check chunk length before deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Feb 28, 2025
1 parent 9fe61b5 commit 7a425ab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions encoding/serialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func (c *Frame) SerializeGnark() ([]byte, error) {
}

func (c *Frame) DeserializeGnark(data []byte) (*Frame, error) {
if len(data) < bn254.SizeOfG1AffineCompressed {
return nil, fmt.Errorf("chunk length must be at least %d: %d given", bn254.SizeOfG1AffineCompressed, len(data))
}
var f Frame
buf := data
err := f.Proof.Unmarshal(buf[:bn254.SizeOfG1AffineCompressed])
Expand Down

0 comments on commit 7a425ab

Please # to comment.