panic: runtime error: slice bounds out of range [:1] with capacity 0
0x34d opened this issue · comments
Reproduce code:
func TestParseDNBug(t *testing.T) {
_, _ = ParseDN(string("=#090180"))
}
run: go test -run TestParseDNBug .
BT:
--- FAIL: TestParseDNBug (0.00s)
panic: runtime error: slice bounds out of range [:1] with capacity 0 [recovered]
panic: runtime error: slice bounds out of range [:1] with capacity 0
goroutine 6 [running]:
testing.tRunner.func1.2({0x7ab260, 0xc00002c390})
/usr/lib/golang/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
/usr/lib/golang/src/testing/testing.go:1529 +0x39f
panic({0x7ab260, 0xc00002c390})
/usr/lib/golang/src/runtime/panic.go:884 +0x213
github.com/go-asn1-ber/asn1-ber.parseBinaryFloat({0xc00002896a?, 0xc0000af6b0?, 0x1?})
/home/0x34d/tools/go/pkg/mod/github.com/go-asn1-ber/asn1-ber@v1.5.4/real.go:98 +0x2d7
github.com/go-asn1-ber/asn1-ber.ParseReal({0xc00002896a?, 0xc00002896a?, 0x1?})
/home/0x34d/tools/go/pkg/mod/github.com/go-asn1-ber/asn1-ber@v1.5.4/real.go:45 +0x78
github.com/go-asn1-ber/asn1-ber.readPacket({0x862460, 0xc0000af680})
/home/0x34d/tools/go/pkg/mod/github.com/go-asn1-ber/asn1-ber@v1.5.4/ber.go:382 +0x4aa
github.com/go-asn1-ber/asn1-ber.DecodePacketErr({0xc000028960, 0x3, 0x8})
/home/0x34d/tools/go/pkg/mod/github.com/go-asn1-ber/asn1-ber@v1.5.4/ber.go:278 +0x74
github.com/go-ldap/ldap.ParseDN({0x7cdfed, 0x8})
/home/0x34d/project/ldap/dn.go:177 +0x36f
github.com/go-ldap/ldap.TestParseDNBug(0x0?)
/home/0x34d/project/ldap/fuzz_test.go:9 +0x25
testing.tRunner(0xc0000deb60, 0x807270)
/usr/lib/golang/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
/usr/lib/golang/src/testing/testing.go:1629 +0x3ea
FAIL github.com/go-ldap/ldap 0.006s
FAIL
I ran into this as well. I've opened an upstream PR
Address panics in parseBinaryFloat, add fuzzer #41
go-asn1-ber/asn1-ber#41