forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: add tendermint/go-amino.DecodeTime (cosmos#9195)
go-amino is a heavily used dependency and given that Tendermrint isn't yet setup for oss-fuzz, this change is a start for it. While here, add the oss-fuzz entry for crypto/types.BitArray CompactUnmarshal fuzzer for PR cosmos#9166. Updates cosmos#7921
- Loading branch information
1 parent
29e8990
commit 4c426df
Showing
14 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
������ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
����؝� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
�墕 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
���� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
���� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
���� |
1 change: 1 addition & 0 deletions
1
fuzz/tendermint/amino/DecodeTime/corpus/9d1996cb2f705ac232aa433ece29827b7939f32d-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 change: 1 addition & 0 deletions
1
fuzz/tendermint/amino/DecodeTime/corpus/bd562f1af1c208bddcc6b5dc96a9265e644774a9-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Binary file added
BIN
+12 Bytes
fuzz/tendermint/amino/DecodeTime/corpus/e26e6189aa4ba285702846e135931b9b29314b32-1
Binary file not shown.
1 change: 1 addition & 0 deletions
1
fuzz/tendermint/amino/DecodeTime/corpus/ff4d5d151fbb8564c87c8358f4de12e218be0488-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}() | ||
} | ||
} |