fuzz: change return values to 1 rather than 0 or -1

This allows gofuzz to store the mutating input as coverage if it reaches
any new coverage, even if it didn't make it to the end of the test.
This commit is contained in:
eugene committed 2020-10-13 15:17:57 -04:00
1 parent d26001a69a
commit f82653cb06
19 files changed
+24 -24

No files matched your search

+2 -2
View File
@@ -32,7 +32,7 @@ func Fuzz_accept_channel(data []byte) int {
payloadLen := uint32(len(data)) - 2
if payloadLen > emptyMsg.MaxPayloadLength(0) {
// Ignore this input - max payload constraint violated.
return -1
return 1
}
msg, err := lnwire.ReadMessage(r, 0)
@@ -40,7 +40,7 @@ func Fuzz_accept_channel(data []byte) int {
// go-fuzz generated []byte that cannot be represented as a
// wire message but we will return 0 so go-fuzz can modify the
// input.
return 0
return 1
}
// We will serialize the message into a new bytes buffer.
+2 -2
View File
@@ -35,7 +35,7 @@ func harness(data []byte, emptyMsg lnwire.Message) int {
payloadLen := uint32(len(data)) - 2
if payloadLen > emptyMsg.MaxPayloadLength(0) {
// Ignore this input - max payload constraint violated.
return -1
return 1
}
msg, err := lnwire.ReadMessage(r, 0)
@@ -43,7 +43,7 @@ func harness(data []byte, emptyMsg lnwire.Message) int {
// go-fuzz generated []byte that cannot be represented as a
// wire message but we will return 0 so go-fuzz can modify the
// input.
return 0
return 1
}
// We will serialize the message into a new bytes buffer.
+2 -2
View File
@@ -32,7 +32,7 @@ func Fuzz_node_announcement(data []byte) int {
payloadLen := uint32(len(data)) - 2
if payloadLen > emptyMsg.MaxPayloadLength(0) {
// Ignore this input - max payload constraint violated.
return -1
return 1
}
msg, err := lnwire.ReadMessage(r, 0)
@@ -40,7 +40,7 @@ func Fuzz_node_announcement(data []byte) int {
// go-fuzz generated []byte that cannot be represented as a
// wire message but we will return 0 so go-fuzz can modify the
// input.
return 0
return 1
}
// We will serialize the message into a new bytes buffer.
+2 -2
View File
@@ -32,7 +32,7 @@ func Fuzz_open_channel(data []byte) int {
payloadLen := uint32(len(data)) - 2
if payloadLen > emptyMsg.MaxPayloadLength(0) {
// Ignore this input - max payload constraint violated.
return -1
return 1
}
msg, err := lnwire.ReadMessage(r, 0)
@@ -40,7 +40,7 @@ func Fuzz_open_channel(data []byte) int {
// go-fuzz generated []byte that cannot be represented as a
// wire message but we will return 0 so go-fuzz can modify the
// input.
return 0
return 1
}
// We will serialize the message into a new bytes buffer.