multiformats / go-multihash

Multihash implementation in Go
MIT License
239 stars 57 forks source link

hasher.Write error is not handled #166

Closed walldiss closed 2 years ago

walldiss commented 2 years ago

Problem

Current implementation of func Sum(data []byte, code uint64, length int) (Multihash, error) doesn't handle error returned from hasher.Write. If there is non-nil error returned it could potentially mean thathasheris not being in valid state to calculate the hash byhasher.Sum()`.

https://github.com/multiformats/go-multihash/blob/196bbeb81a568a71ec224866ccc68c1f28a272d8/sum.go#L27