Skip to content

errors: do not report a unhandled error on hash.Hash.Write code which by contract WILL NEVER return an error #45

@odeke-em

Description

@odeke-em

Summary

We've got reports for hashing algorithms not handling errors for example

[/Users/emmanuelodeke/go/src/github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1/secp256k1.go:160] - G104 (CWE-703): Errors unhandled. (Confidence: HIGH, Severity: LOW)
    159: 	hasherRIPEMD160 := ripemd160.New()
  > 160: 	hasherRIPEMD160.Write(sha[:]) // does not error
    161: 	return crypto.Address(hasherRIPEMD160.Sum(nil))

but the Go contracts for hash.Hash.Write say that it WILL NEVER return an error per https://pkg.go.dev/hash#Hash
Screen Shot 2022-09-23 at 6 48 28 PM

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingux

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions