Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
fuzz: return nil if len(keys) is zero (#55)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odeke-em authored Aug 15, 2021
1 parent f0f62d6 commit a99c0f5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fuzz/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func Fuzz(input []byte) int {
keys = append(keys, k)
return k
}
if len(keys) == 0 {
return nil
}
return keys[int(readByte(r))%len(keys)]
}
for i := 0; r.Len() != 0; i++ {
Expand Down

0 comments on commit a99c0f5

Please sign in to comment.