celestiaorg / smt

A Go library that implements a Sparse Merkle tree for a key-value map.
https://godoc.org/github.com/celestiaorg/smt
MIT License
138 stars 53 forks source link

fuzz: return nil if len(keys) is zero #55

Closed odeke-em closed 3 years ago

odeke-em commented 3 years ago

Fixes a divide by zero exception which resulted from a modulo operation using keys that were non-existent. oss-fuzz reported a crash

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37182

but that was a fault in the fuzzing code, and not in smt.

odeke-em commented 3 years ago

/cc @cuonglm @liamsi

codecov-commenter commented 3 years ago

Codecov Report

Merging #55 (23d38e6) into master (a8b51d5) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #55   +/-   ##
=======================================
  Coverage   85.68%   85.68%           
=======================================
  Files           6        6           
  Lines         468      468           
=======================================
  Hits          401      401           
  Misses         39       39           
  Partials       28       28           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f0f62d6...23d38e6. Read the comment docs.

odeke-em commented 3 years ago

Thank you @adlerjohn and @cuonglm for the review!