diff --git a/fuzz/oss-fuzz-build.sh b/fuzz/oss-fuzz-build.sh index 216132c5e04f..6bb4103753df 100644 --- a/fuzz/oss-fuzz-build.sh +++ b/fuzz/oss-fuzz-build.sh @@ -4,6 +4,10 @@ export FUZZ_ROOT="github.com/cosmos/cosmos-sdk" compile_go_fuzzer "$FUZZ_ROOT"/fuzz/crypto/hd/deriveprivatekeyforpath Fuzz fuzz_crypto_hd_deriveprivatekeyforpath fuzz +compile_go_fuzzer "$FUZZ_ROOT"/fuzz/crypto/types/compactbitarray/marshalunmarshal Fuzz fuzz_crypto_types_compactbitarray_marshalunmarshal fuzz + +compile_go_fuzzer "$FUZZ_ROOT"/fuzz/tendermint/amino/decodetime Fuzz fuzz_tendermint_amino_decodetime fuzz + compile_go_fuzzer "$FUZZ_ROOT"/fuzz/types/parsecoin Fuzz fuzz_types_parsecoin fuzz compile_go_fuzzer "$FUZZ_ROOT"/fuzz/types/parsedeccoin Fuzz fuzz_types_parsedeccoin fuzz compile_go_fuzzer "$FUZZ_ROOT"/fuzz/types/parsetimebytes Fuzz fuzz_types_parsetimebytes fuzz diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/1.txt b/fuzz/tendermint/amino/DecodeTime/corpus/1.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/2.txt b/fuzz/tendermint/amino/DecodeTime/corpus/2.txt new file mode 100644 index 000000000000..c9ec833cb4de --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/2.txt @@ -0,0 +1 @@ +ΆΓ„ˆŒš \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/3.txt b/fuzz/tendermint/amino/DecodeTime/corpus/3.txt new file mode 100644 index 000000000000..653450b7f5e3 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/3.txt @@ -0,0 +1 @@ +ΐ¦½‡؝θ \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/4.txt b/fuzz/tendermint/amino/DecodeTime/corpus/4.txt new file mode 100644 index 000000000000..6350d0750e5a --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/4.txt @@ -0,0 +1 @@ +Άε’•π“š \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/5.txt b/fuzz/tendermint/amino/DecodeTime/corpus/5.txt new file mode 100644 index 000000000000..3c3068c10f51 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/5.txt @@ -0,0 +1 @@ +φΏ£„π“š \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/6.txt b/fuzz/tendermint/amino/DecodeTime/corpus/6.txt new file mode 100644 index 000000000000..86006636f4c7 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/6.txt @@ -0,0 +1 @@ +φΖχƒπ“š \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/7.txt b/fuzz/tendermint/amino/DecodeTime/corpus/7.txt new file mode 100644 index 000000000000..37444c7f7a45 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/7.txt @@ -0,0 +1 @@ +Ά‘ψςπ“š \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/9d1996cb2f705ac232aa433ece29827b7939f32d-1 b/fuzz/tendermint/amino/DecodeTime/corpus/9d1996cb2f705ac232aa433ece29827b7939f32d-1 new file mode 100644 index 000000000000..3dc87bb2c1c5 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/9d1996cb2f705ac232aa433ece29827b7939f32d-1 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/bd562f1af1c208bddcc6b5dc96a9265e644774a9-1 b/fuzz/tendermint/amino/DecodeTime/corpus/bd562f1af1c208bddcc6b5dc96a9265e644774a9-1 new file mode 100644 index 000000000000..d65dd8f1d544 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/bd562f1af1c208bddcc6b5dc96a9265e644774a9-1 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/e26e6189aa4ba285702846e135931b9b29314b32-1 b/fuzz/tendermint/amino/DecodeTime/corpus/e26e6189aa4ba285702846e135931b9b29314b32-1 new file mode 100644 index 000000000000..e7b1d3ac9d3d Binary files /dev/null and b/fuzz/tendermint/amino/DecodeTime/corpus/e26e6189aa4ba285702846e135931b9b29314b32-1 differ diff --git a/fuzz/tendermint/amino/DecodeTime/corpus/ff4d5d151fbb8564c87c8358f4de12e218be0488-1 b/fuzz/tendermint/amino/DecodeTime/corpus/ff4d5d151fbb8564c87c8358f4de12e218be0488-1 new file mode 100644 index 000000000000..9fda2b299abd --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/corpus/ff4d5d151fbb8564c87c8358f4de12e218be0488-1 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fuzz/tendermint/amino/DecodeTime/fuzz.go b/fuzz/tendermint/amino/DecodeTime/fuzz.go new file mode 100644 index 000000000000..8bb5e364ac53 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/fuzz.go @@ -0,0 +1,24 @@ +package decodetime + +import ( + "fmt" + + amino "github.com/tendermint/go-amino" +) + +func Fuzz(data []byte) int { + if len(data) == 0 { + return -1 + } + t, n, err := amino.DecodeTime(data) + if err != nil { + return -1 + } + if n < 0 { + panic(fmt.Sprintf("n=%d < 0", n)) + } + if t.IsZero() { + return 0 + } + return 1 +} diff --git a/fuzz/tendermint/amino/DecodeTime/gen/main.go b/fuzz/tendermint/amino/DecodeTime/gen/main.go new file mode 100644 index 000000000000..1357c41f7043 --- /dev/null +++ b/fuzz/tendermint/amino/DecodeTime/gen/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "os" + "time" + + amino "github.com/tendermint/go-amino" +) + +func main() { + times := []time.Time{ + time.Unix(0, 0), + time.Now(), + time.Date(1979, time.January, 02, 10, 11, 12, 7999192, time.UTC), + time.Now().Add(10000 * time.Hour), + time.Now().Add(100 * time.Hour), + time.Now().Add(-100 * time.Hour), + time.Now().Add(-10000 * time.Hour), + } + + for i, t := range times { + func() { + f, err := os.Create(fmt.Sprintf("%d.txt", i+1)) + if err != nil { + panic(err) + } + defer f.Close() + + if err := amino.EncodeTime(f, t); err != nil { + panic(err) + } + }() + } +}