Skip to content

Commit

Permalink
storage/mkvs: Fix proof verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Feb 21, 2020
1 parent 23859e9 commit 1e4cef3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/2703.bugfix.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage/mkvs: Fix proof verifier
5 changes: 4 additions & 1 deletion go/storage/mkvs/urkel/syncer/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (pv *ProofVerifier) VerifyProof(ctx context.Context, root hash.Hash, proof
if !rootNodeHash.Equal(&root) {
return nil, fmt.Errorf("verifier: bad root (expected: %s got: %s)",
root,
rootNode.Hash,
rootNodeHash,
)
}
return rootNode, nil
Expand All @@ -205,6 +205,9 @@ func (pv *ProofVerifier) verifyProof(ctx context.Context, proof *Proof, idx int)
if entry == nil {
return idx + 1, nil, nil
}
if len(entry) == 0 {
return -1, nil, errors.New("verifier: malformed proof")
}

switch entry[0] {
case proofEntryFull:
Expand Down
3 changes: 3 additions & 0 deletions runtime/src/storage/mkvs/urkel/sync/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ impl ProofVerifier {
Some(entry) => entry.as_ref(),
None => return Ok((idx + 1, NodePointer::null_ptr())),
};
if entry.is_empty() {
return Err(format_err!("verifier: malformed proof"));
}

match entry[0] {
PROOF_ENTRY_FULL => {
Expand Down

0 comments on commit 1e4cef3

Please sign in to comment.