tiff: add Fuzz function

This change adds a sample Fuzz test function to package tiff, under
the gofuzz build tag. The function is based on the tiff/tiff.go code,
from github.com/dvyukov/go-fuzz-corpus.

Fixes golang/go#30719
Updates golang/go#19109

Change-Id: I78771e9a1bd01651ba6ca421ba41f0c0e95d0c53
Reviewed-on: https://go-review.googlesource.com/c/image/+/167097
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: thepudds <thepudds1460@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
diff --git a/tiff/fuzz.go b/tiff/fuzz.go
new file mode 100644
index 0000000..ec52c78
--- /dev/null
+++ b/tiff/fuzz.go
@@ -0,0 +1,29 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gofuzz
+
+package tiff
+
+import "bytes"
+
+func Fuzz(data []byte) int {
+	cfg, err := DecodeConfig(bytes.NewReader(data))
+	if err != nil {
+		return 0
+	}
+	if cfg.Width*cfg.Height > 1e6 {
+		return 0
+	}
+	img, err := Decode(bytes.NewReader(data))
+	if err != nil {
+		return 0
+	}
+	var w bytes.Buffer
+	err = Encode(&w, img, nil)
+	if err != nil {
+		panic(err)
+	}
+	return 1
+}