Skip to content

Commit

Permalink
fix(actors): address codeql complaint (filecoin-project#12454)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg authored and rjan90 committed Sep 12, 2024
1 parent c72c6ac commit e4a9614
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 58 deletions.
23 changes: 0 additions & 23 deletions chain/actors/builtin/multisig/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,6 @@ type ProposeReturn = msig{{.latestVersion}}.ProposeReturn
type ProposeParams = msig{{.latestVersion}}.ProposeParams
type ApproveReturn = msig{{.latestVersion}}.ApproveReturn

func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig{{.latestVersion}}.TxnIDParams{ID: msig{{.latestVersion}}.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
}
if data.Value.Sign() == -1 {
return nil, xerrors.Errorf("proposal value must be non-negative, was %s", data.Value)
}
if data.To == address.Undef {
return nil, xerrors.Errorf("proposed destination address must be set")
}
pser, err := data.Serialize()
if err != nil {
return nil, err
}
hash := blake2b.Sum256(pser)
params.ProposalHash = hash[:]
}

return actors.SerializeParams(&params)
}

func AllCodes() []cid.Cid {
return []cid.Cid{ {{range .versions}}
(&state{{.}}{}).Code(),
Expand Down
54 changes: 42 additions & 12 deletions chain/actors/builtin/multisig/message.go.template

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions chain/actors/builtin/multisig/message0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions chain/actors/builtin/multisig/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,6 @@ type ProposeReturn = msig15.ProposeReturn
type ProposeParams = msig15.ProposeParams
type ApproveReturn = msig15.ApproveReturn

func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig15.TxnIDParams{ID: msig15.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
}
if data.Value.Sign() == -1 {
return nil, xerrors.Errorf("proposal value must be non-negative, was %s", data.Value)
}
if data.To == address.Undef {
return nil, xerrors.Errorf("proposed destination address must be set")
}
pser, err := data.Serialize()
if err != nil {
return nil, err
}
hash := blake2b.Sum256(pser)
params.ProposalHash = hash[:]
}

return actors.SerializeParams(&params)
}

func AllCodes() []cid.Cid {
return []cid.Cid{
(&state0{}).Code(),
Expand Down

0 comments on commit e4a9614

Please sign in to comment.