File: fuzz.go

package info (click to toggle)
golang-github-gocql-gocql 0.0~git20191102.0.9faa4c0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,012 kB
  • sloc: sh: 84; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 436 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// +build gofuzz

package gocql

import "bytes"

func Fuzz(data []byte) int {
	var bw bytes.Buffer

	r := bytes.NewReader(data)

	head, err := readHeader(r, make([]byte, 9))
	if err != nil {
		return 0
	}

	framer := newFramer(r, &bw, nil, byte(head.version))
	err = framer.readFrame(&head)
	if err != nil {
		return 0
	}

	frame, err := framer.parseFrame()
	if err != nil {
		return 0
	}

	if frame != nil {
		return 1
	}

	return 2
}