File: fuzz.go

package info (click to toggle)
golang-github-bkaradzic-go-lz4 1.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 688 kB
  • sloc: makefile: 7
file content (23 lines) | stat: -rw-r--r-- 271 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// +build gofuzz

package lz4

import "encoding/binary"

func Fuzz(data []byte) int {

	if len(data) < 4 {
		return 0
	}

	ln := binary.LittleEndian.Uint32(data)
	if ln > (1 << 21) {
		return 0
	}

	if _, err := Decode(nil, data); err != nil {
		return 0
	}

	return 1
}