move fuzz files, fix crasher

This commit is contained in:
Hayden
2017-04-16 21:02:47 -07:00
parent 95d65ab0a0
commit b2bae2c198
53 changed files with 80 additions and 33 deletions

View File

@ -1,8 +0,0 @@
fuzz:
go-fuzz-build -o lib/common/fuzz/keys_and_cert/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/keys_and_cert
go-fuzz-build -o lib/common/fuzz/certificate/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/certificate
go-fuzz-build -o lib/common/fuzz/destination/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/destination
go-fuzz-build -o lib/common/fuzz/router_address/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/router_address
go-fuzz-build -o lib/common/fuzz/router_identity/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/router_identity
go-fuzz-build -o lib/common/fuzz/string/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/string
forego start

View File

@ -1,6 +0,0 @@
keys_and_cert: go-fuzz -bin=lib/common/fuzz/keys_and_cert/exportable-fuzz.zip -workdir=lib/common/fuzz/keys_and_cert -procs=1
certificate: go-fuzz -bin=lib/common/fuzz/certificate/exportable-fuzz.zip -workdir=lib/common/fuzz/certificate -procs=1
destination: go-fuzz -bin=lib/common/fuzz/destination/exportable-fuzz.zip -workdir=lib/common/fuzz/destination -procs=1
router_address: go-fuzz -bin=lib/common/fuzz/router_address/exportable-fuzz.zip -workdir=lib/common/fuzz/router_address -procs=1
router_identity: go-fuzz -bin=lib/common/fuzz/router_identity/exportable-fuzz.zip -workdir=lib/common/fuzz/router_identity -procs=1
string: go-fuzz -bin=lib/common/fuzz/string/exportable-fuzz.zip -workdir=lib/common/fuzz/string -procs=1

8
lib/common/fuzz/Makefile Normal file
View File

@ -0,0 +1,8 @@
fuzz:
go-fuzz-build -o keys_and_cert/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/keys_and_cert
go-fuzz-build -o certificate/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/certificate
go-fuzz-build -o destination/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/destination
go-fuzz-build -o router_address/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/router_address
go-fuzz-build -o router_identity/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/router_identity
go-fuzz-build -o string/exportable-fuzz.zip github.com/hkparker/go-i2p/lib/common/fuzz/string
forego start

6
lib/common/fuzz/Procfile Normal file
View File

@ -0,0 +1,6 @@
keys_and_cert: go-fuzz -bin=keys_and_cert/exportable-fuzz.zip -workdir=lib/common/fuzz/keys_and_cert -procs=2
certificate: go-fuzz -bin=certificate/exportable-fuzz.zip -workdir=lib/common/fuzz/certificate -procs=2
destination: go-fuzz -bin=destination/exportable-fuzz.zip -workdir=lib/common/fuzz/destination -procs=2
router_address: go-fuzz -bin=router_address/exportable-fuzz.zip -workdir=lib/common/fuzz/router_address -procs=2
router_identity: go-fuzz -bin=router_identity/exportable-fuzz.zip -workdir=lib/common/fuzz/router_identity -procs=2
string: go-fuzz -bin=string/exportable-fuzz.zip -workdir=lib/common/fuzz/string -procs=2

View File

@ -0,0 +1 @@
A<EFBFBD><EFBFBD><EFBFBD>q

View File

@ -0,0 +1 @@
Bnzero lpngth explicit tag was not an Psn-1060808735Flag

View File

@ -0,0 +1 @@
<EFBFBD>3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f%

View File

@ -0,0 +1 @@
Bnzero lpngth explicit tag wa6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151s not an Psn-1060808735Flag

View File

@ -0,0 +1 @@
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_

View File

@ -0,0 +1 @@
<EFBFBD>indefinite length

View File

@ -0,0 +1 @@
0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@ -0,0 +1,19 @@
time="2017-04-16T20:54:53-07:00" level=warning msg="string format warning" at="(String) Length" expected_bytes_length=1 reason="data longer than specified" string_bytes_length=3 string_length_field=0
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
panic(0x561068e6e880, 0xc42000c1f0)
/tmp/go-fuzz-build725797872/goroot/src/runtime/panic.go:500 +0x1a1
github.com/hkparker/go-i2p/lib/common.ReadRouterAddress(0x7f11abe00000, 0xc, 0x200000, 0x10, 0x550, 0x56, 0xc420055e88, 0x561068dcccd3, 0x58f43c8d, 0xca6e39e, ...)
/tmp/go-fuzz-build725797872/gopath/src/github.com/hkparker/go-i2p/lib/common/router_address.go:153 +0x450
github.com/hkparker/go-i2p/lib/common/fuzz/router_address.Fuzz(0x7f11abe00000, 0xc, 0x200000, 0x0)
/tmp/go-fuzz-build725797872/gopath/src/github.com/hkparker/go-i2p/lib/common/fuzz/router_address/fuzz.go:6 +0x4c
go-fuzz-dep.Main(0x561068e969e8)
/tmp/go-fuzz-build725797872/goroot/src/go-fuzz-dep/main.go:49 +0xe8
main.main()
/tmp/go-fuzz-build725797872/gopath/src/github.com/hkparker/go-i2p/lib/common/fuzz/router_address/go.fuzz.main/main.go:10 +0x2d
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/tmp/go-fuzz-build725797872/goroot/src/runtime/asm_amd64.s:2086 +0x1
exit status 2

View File

@ -0,0 +1,6 @@
panic: runtime error: slice bounds out of range
panic
github.com/hkparker/go-i2p/lib/common.ReadRouterAddress
github.com/hkparker/go-i2p/lib/common/fuzz/router_address.Fuzz
go-fuzz-dep.Main
main.main

View File

@ -1,19 +0,0 @@
time="2017-04-07T21:24:51-07:00" level=warning msg="string format warning" at="(String) Length" expected_bytes_length=1 reason="data longer than specified" string_bytes_length=3 string_length_field=0
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
panic(0x55732ff677e0, 0xc42000c1f0)
/tmp/go-fuzz-build303011531/goroot/src/runtime/panic.go:500 +0x1a1
github.com/hkparker/go-i2p/lib/common.ReadRouterAddress(0x7ff24dbe0000, 0xc, 0x200000, 0x10, 0x350, 0x36, 0xc420053e88, 0x55732fec5cd3, 0x58e86613, 0x3747c069, ...)
/tmp/go-fuzz-build303011531/gopath/src/github.com/hkparker/go-i2p/lib/common/router_address.go:152 +0x450
github.com/hkparker/go-i2p/lib/common/fuzz/router_address.Fuzz(0x7ff24dbe0000, 0xc, 0x200000, 0x0)
/tmp/go-fuzz-build303011531/gopath/src/github.com/hkparker/go-i2p/lib/common/fuzz/router_address/fuzz.go:6 +0x4c
go-fuzz-dep.Main(0x55732ff8f948)
/tmp/go-fuzz-build303011531/goroot/src/go-fuzz-dep/main.go:49 +0xe8
main.main()
/tmp/go-fuzz-build303011531/gopath/src/github.com/hkparker/go-i2p/lib/common/fuzz/router_address/go.fuzz.main/main.go:10 +0x2d
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/tmp/go-fuzz-build303011531/goroot/src/runtime/asm_amd64.s:2086 +0x1
exit status 2

View File

@ -0,0 +1 @@
<EFBFBD>c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3

View File

@ -0,0 +1 @@
<EFBFBD>

View File

@ -146,9 +146,16 @@ func ReadRouterAddress(data []byte) (router_address RouterAddress, remainder []b
mapping := make([]byte, 0) mapping := make([]byte, 0)
if len(remainder) >= 2 { if len(remainder) >= 2 {
map_size = Integer(remainder[:2]) map_size = Integer(remainder[:2])
if len(remainder) < map_size+2 {
err = errors.New("not enough data for map inside router address")
router_address = RouterAddress([]byte{})
remainder = []byte{}
return
}
mapping = remainder[:map_size+2] mapping = remainder[:map_size+2]
router_address = append(router_address, mapping...) router_address = append(router_address, mapping...)
} }
remainder = data[ROUTER_ADDRESS_MIN_SIZE+len(str)+len(mapping):] remainder = data[ROUTER_ADDRESS_MIN_SIZE+len(str)+len(mapping):]
return return
} }

View File

@ -82,3 +82,16 @@ func TestReadRouterAddressReturnsCorrectRemainderWithoutError(t *testing.T) {
assert.Nil(err, "checkValid() on address from ReadRouterAddress() reported error with valid data") assert.Nil(err, "checkValid() on address from ReadRouterAddress() reported error with valid data")
assert.Equal(exit, false, "checkValid() on address from ReadRouterAddress() indicated to stop parsing valid data") assert.Equal(exit, false, "checkValid() on address from ReadRouterAddress() indicated to stop parsing valid data")
} }
func TestCorrectsFuzzCrasher1(t *testing.T) {
assert := assert.New(t)
defer func() {
if r := recover(); r != nil {
assert.Equal(nil, r)
}
}()
router_address_bytes := []byte{0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30}
ReadRouterAddress(router_address_bytes)
}