...

Source file src/golang.org/x/image/tiff/fuzz.go

Documentation: golang.org/x/image/tiff

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build gofuzz
     6  
     7  package tiff
     8  
     9  import "bytes"
    10  
    11  func Fuzz(data []byte) int {
    12  	cfg, err := DecodeConfig(bytes.NewReader(data))
    13  	if err != nil {
    14  		return 0
    15  	}
    16  	if cfg.Width*cfg.Height > 1e6 {
    17  		return 0
    18  	}
    19  	img, err := Decode(bytes.NewReader(data))
    20  	if err != nil {
    21  		return 0
    22  	}
    23  	var w bytes.Buffer
    24  	err = Encode(&w, img, nil)
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  	return 1
    29  }
    30  

View as plain text