gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

fuzz.go (549B)


      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 // +build gofuzz
      7 
      8 package tiff
      9 
     10 import "bytes"
     11 
     12 func Fuzz(data []byte) int {
     13 	cfg, err := DecodeConfig(bytes.NewReader(data))
     14 	if err != nil {
     15 		return 0
     16 	}
     17 	if cfg.Width*cfg.Height > 1e6 {
     18 		return 0
     19 	}
     20 	img, err := Decode(bytes.NewReader(data))
     21 	if err != nil {
     22 		return 0
     23 	}
     24 	var w bytes.Buffer
     25 	err = Encode(&w, img, nil)
     26 	if err != nil {
     27 		panic(err)
     28 	}
     29 	return 1
     30 }