Skip to content

Commit

Permalink
check duplicated key in verify header (#1382)
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy authored Dec 30, 2021
1 parent 94bb19f commit 61d6547
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/store/ledgerstore/ledger_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,17 @@ func (this *LedgerStoreImp) verifyHeader(header *types.Header) error {
if len(header.Bookkeepers) < m {
return fmt.Errorf("header Bookkeepers %d more than 6/7 len vbftPeerInfo%d", len(header.Bookkeepers), len(vbftPeerInfo))
}
usedPubKey := make(map[string]bool)
for _, bookkeeper := range header.Bookkeepers {
pubkey := vconfig.PubkeyID(bookkeeper)
_, present := vbftPeerInfo[pubkey]
if !present {
if !present || usedPubKey[pubkey] {
val, _ := json.Marshal(vbftPeerInfo)
log.Errorf("verify header error: invalid pubkey :%v, height:%d, current vbftPeerInfo :%s",
pubkey, header.Height, string(val))
return fmt.Errorf("verify header error: invalid pubkey : %v", pubkey)
}
usedPubKey[pubkey] = true
}
hash := header.Hash()
err = signature.VerifyMultiSignature(hash[:], header.Bookkeepers, m, header.SigData)
Expand Down

0 comments on commit 61d6547

Please sign in to comment.