2
0
Files
pgx/pgproto3/fuzz_test.go
T
Jack Christensen 9d0f27bc4b Initial fuzz testing and fix
Initial fuzz testing of pgproto3 found a panic
2022-07-23 15:22:28 -05:00

30 lines
518 B
Go

package pgproto3_test
import (
"bytes"
"testing"
"github.com/jackc/pgx/v5/pgproto3"
"github.com/stretchr/testify/require"
)
func FuzzFrontend(f *testing.F) {
testcases := [][]byte{
{'Z', 0, 0, 0, 5},
}
for _, tc := range testcases {
f.Add(tc)
}
f.Fuzz(func(t *testing.T, encodedMsg []byte) {
r := &bytes.Buffer{}
w := &bytes.Buffer{}
fe := pgproto3.NewFrontend(r, w)
_, err := r.Write(encodedMsg)
require.NoError(t, err)
// Not checking anything other than no panic.
fe.Receive()
})
}