tiff: consistently skip horizontal padding in tiled images

The rightmost tiles of a tiled image can extend past the right
edge of the image. When this happens, we should skip over the
out-of-bounds data.

For example, consider a 2x2 image with an 4x4 tile size:

	xx..
	xx..
	....
	....

When decoding, we must skip over the padding (dots) at the end of each row.

This skip was present for 16bpp greyscale images, but missing
for a number of other cases. Add the missing skips where absent.

Add a collection of test images for various image formats
containing a tile larger than the image size.

(Credit to Gemini for pointing out the bug and creating the test data.)

Change-Id: I72cc342deb3f3a714ab7aa8f8111c7bd6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/image/+/790222
Auto-Submit: Damien Neil <dneil@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Neal Patel <neal@golang.org>
Reviewed-by: Neal Patel <nealpatel@google.com>
15 files changed
tree: a9d29405b62033856aef9a2611846bdacddd6c1e
  1. bmp/
  2. ccitt/
  3. cmd/
  4. colornames/
  5. draw/
  6. example/
  7. font/
  8. internal/
  9. math/
  10. riff/
  11. testdata/
  12. tiff/
  13. vector/
  14. vp8/
  15. vp8l/
  16. webp/
  17. .gitattributes
  18. .gitignore
  19. codereview.cfg
  20. CONTRIBUTING.md
  21. go.mod
  22. go.sum
  23. LICENSE
  24. PATENTS
  25. README.md
README.md

Go Images

Go Reference

This repository holds supplementary Go image packages.

Security Considerations

The packages in this repository have the same security model as the standard library image package. Specifically, when operating on arbitrary images, DecodeConfig should be called before Decode, so that the program can decide whether the image, as defined in the returned header, can be safely decoded with the available resources. A call to Decode which produces an extremely large image, as defined in the header returned by DecodeConfig, is not considered a security issue, regardless of whether the image is itself malformed or not.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/image.

The main issue tracker for the image repository is located at https://go.dev/issues. Prefix your issue with “x/image:” in the subject line, so it is easy to find.