mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Bump golang.org/x/image from 0.0.0-20210220032944-ac19c3e999fb to 0.5.0 (#3494)
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.0.0-20210220032944-ac19c3e999fb to 0.5.0. - [Release notes](https://github.com/golang/image/releases) - [Commits](https://github.com/golang/image/commits/v0.5.0) --- updated-dependencies: - dependency-name: golang.org/x/image dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
30809e16fa
commit
078f99a7ec
10 changed files with 549 additions and 481 deletions
4
go.mod
4
go.mod
|
|
@ -35,7 +35,7 @@ require (
|
||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
github.com/vektra/mockery/v2 v2.10.0
|
github.com/vektra/mockery/v2 v2.10.0
|
||||||
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064
|
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064
|
||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
golang.org/x/image v0.5.0
|
||||||
golang.org/x/net v0.7.0
|
golang.org/x/net v0.7.0
|
||||||
golang.org/x/sys v0.5.0
|
golang.org/x/sys v0.5.0
|
||||||
golang.org/x/term v0.5.0
|
golang.org/x/term v0.5.0
|
||||||
|
|
@ -57,7 +57,6 @@ require (
|
||||||
github.com/spf13/cast v1.4.1
|
github.com/spf13/cast v1.4.1
|
||||||
github.com/vearutop/statigz v1.1.6
|
github.com/vearutop/statigz v1.1.6
|
||||||
github.com/vektah/dataloaden v0.3.0
|
github.com/vektah/dataloaden v0.3.0
|
||||||
github.com/vektah/gqlparser/v2 v2.5.1
|
|
||||||
github.com/xWTF/chardet v0.0.0-20230208095535-c780f2ac244e
|
github.com/xWTF/chardet v0.0.0-20230208095535-c780f2ac244e
|
||||||
gopkg.in/guregu/null.v4 v4.0.0
|
gopkg.in/guregu/null.v4 v4.0.0
|
||||||
)
|
)
|
||||||
|
|
@ -100,6 +99,7 @@ require (
|
||||||
github.com/subosito/gotenv v1.2.0 // indirect
|
github.com/subosito/gotenv v1.2.0 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/urfave/cli/v2 v2.8.1 // indirect
|
github.com/urfave/cli/v2 v2.8.1 // indirect
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -849,8 +849,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
|
||||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
|
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
|
|
||||||
3
vendor/golang.org/x/image/AUTHORS
generated
vendored
3
vendor/golang.org/x/image/AUTHORS
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
# This source code refers to The Go Authors for copyright purposes.
|
|
||||||
# The master list of authors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/AUTHORS.
|
|
||||||
3
vendor/golang.org/x/image/CONTRIBUTORS
generated
vendored
3
vendor/golang.org/x/image/CONTRIBUTORS
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
# This source code was written by the Go contributors.
|
|
||||||
# The master list of contributors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
|
||||||
70
vendor/golang.org/x/image/bmp/reader.go
generated
vendored
70
vendor/golang.org/x/image/bmp/reader.go
generated
vendored
|
|
@ -85,7 +85,7 @@ func decodeRGB(r io.Reader, c image.Config, topDown bool) (image.Image, error) {
|
||||||
|
|
||||||
// decodeNRGBA reads a 32 bit-per-pixel BMP image from r.
|
// decodeNRGBA reads a 32 bit-per-pixel BMP image from r.
|
||||||
// If topDown is false, the image rows will be read bottom-up.
|
// If topDown is false, the image rows will be read bottom-up.
|
||||||
func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error) {
|
func decodeNRGBA(r io.Reader, c image.Config, topDown, allowAlpha bool) (image.Image, error) {
|
||||||
rgba := image.NewNRGBA(image.Rect(0, 0, c.Width, c.Height))
|
rgba := image.NewNRGBA(image.Rect(0, 0, c.Width, c.Height))
|
||||||
if c.Width == 0 || c.Height == 0 {
|
if c.Width == 0 || c.Height == 0 {
|
||||||
return rgba, nil
|
return rgba, nil
|
||||||
|
|
@ -102,6 +102,9 @@ func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error)
|
||||||
for i := 0; i < len(p); i += 4 {
|
for i := 0; i < len(p); i += 4 {
|
||||||
// BMP images are stored in BGRA order rather than RGBA order.
|
// BMP images are stored in BGRA order rather than RGBA order.
|
||||||
p[i+0], p[i+2] = p[i+2], p[i+0]
|
p[i+0], p[i+2] = p[i+2], p[i+0]
|
||||||
|
if !allowAlpha {
|
||||||
|
p[i+3] = 0xFF
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rgba, nil
|
return rgba, nil
|
||||||
|
|
@ -110,7 +113,7 @@ func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error)
|
||||||
// Decode reads a BMP image from r and returns it as an image.Image.
|
// Decode reads a BMP image from r and returns it as an image.Image.
|
||||||
// Limitation: The file must be 8, 24 or 32 bits per pixel.
|
// Limitation: The file must be 8, 24 or 32 bits per pixel.
|
||||||
func Decode(r io.Reader) (image.Image, error) {
|
func Decode(r io.Reader) (image.Image, error) {
|
||||||
c, bpp, topDown, err := decodeConfig(r)
|
c, bpp, topDown, allowAlpha, err := decodeConfig(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +123,7 @@ func Decode(r io.Reader) (image.Image, error) {
|
||||||
case 24:
|
case 24:
|
||||||
return decodeRGB(r, c, topDown)
|
return decodeRGB(r, c, topDown)
|
||||||
case 32:
|
case 32:
|
||||||
return decodeNRGBA(r, c, topDown)
|
return decodeNRGBA(r, c, topDown, allowAlpha)
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
|
|
@ -129,13 +132,15 @@ func Decode(r io.Reader) (image.Image, error) {
|
||||||
// decoding the entire image.
|
// decoding the entire image.
|
||||||
// Limitation: The file must be 8, 24 or 32 bits per pixel.
|
// Limitation: The file must be 8, 24 or 32 bits per pixel.
|
||||||
func DecodeConfig(r io.Reader) (image.Config, error) {
|
func DecodeConfig(r io.Reader) (image.Config, error) {
|
||||||
config, _, _, err := decodeConfig(r)
|
config, _, _, _, err := decodeConfig(r)
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown bool, err error) {
|
func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown bool, allowAlpha bool, err error) {
|
||||||
// We only support those BMP images that are a BITMAPFILEHEADER
|
// We only support those BMP images with one of the following DIB headers:
|
||||||
// immediately followed by a BITMAPINFOHEADER.
|
// - BITMAPINFOHEADER (40 bytes)
|
||||||
|
// - BITMAPV4HEADER (108 bytes)
|
||||||
|
// - BITMAPV5HEADER (124 bytes)
|
||||||
const (
|
const (
|
||||||
fileHeaderLen = 14
|
fileHeaderLen = 14
|
||||||
infoHeaderLen = 40
|
infoHeaderLen = 40
|
||||||
|
|
@ -147,21 +152,21 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = io.ErrUnexpectedEOF
|
err = io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
return image.Config{}, 0, false, err
|
return image.Config{}, 0, false, false, err
|
||||||
}
|
}
|
||||||
if string(b[:2]) != "BM" {
|
if string(b[:2]) != "BM" {
|
||||||
return image.Config{}, 0, false, errors.New("bmp: invalid format")
|
return image.Config{}, 0, false, false, errors.New("bmp: invalid format")
|
||||||
}
|
}
|
||||||
offset := readUint32(b[10:14])
|
offset := readUint32(b[10:14])
|
||||||
infoLen := readUint32(b[14:18])
|
infoLen := readUint32(b[14:18])
|
||||||
if infoLen != infoHeaderLen && infoLen != v4InfoHeaderLen && infoLen != v5InfoHeaderLen {
|
if infoLen != infoHeaderLen && infoLen != v4InfoHeaderLen && infoLen != v5InfoHeaderLen {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
if _, err := io.ReadFull(r, b[fileHeaderLen+4:fileHeaderLen+infoLen]); err != nil {
|
if _, err := io.ReadFull(r, b[fileHeaderLen+4:fileHeaderLen+infoLen]); err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = io.ErrUnexpectedEOF
|
err = io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
return image.Config{}, 0, false, err
|
return image.Config{}, 0, false, false, err
|
||||||
}
|
}
|
||||||
width := int(int32(readUint32(b[18:22])))
|
width := int(int32(readUint32(b[18:22])))
|
||||||
height := int(int32(readUint32(b[22:26])))
|
height := int(int32(readUint32(b[22:26])))
|
||||||
|
|
@ -169,12 +174,12 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b
|
||||||
height, topDown = -height, true
|
height, topDown = -height, true
|
||||||
}
|
}
|
||||||
if width < 0 || height < 0 {
|
if width < 0 || height < 0 {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
// We only support 1 plane and 8, 24 or 32 bits per pixel and no
|
// We only support 1 plane and 8, 24 or 32 bits per pixel and no
|
||||||
// compression.
|
// compression.
|
||||||
planes, bpp, compression := readUint16(b[26:28]), readUint16(b[28:30]), readUint32(b[30:34])
|
planes, bpp, compression := readUint16(b[26:28]), readUint16(b[28:30]), readUint32(b[30:34])
|
||||||
// if compression is set to BITFIELDS, but the bitmask is set to the default bitmask
|
// if compression is set to BI_BITFIELDS, but the bitmask is set to the default bitmask
|
||||||
// that would be used if compression was set to 0, we can continue as if compression was 0
|
// that would be used if compression was set to 0, we can continue as if compression was 0
|
||||||
if compression == 3 && infoLen > infoHeaderLen &&
|
if compression == 3 && infoLen > infoHeaderLen &&
|
||||||
readUint32(b[54:58]) == 0xff0000 && readUint32(b[58:62]) == 0xff00 &&
|
readUint32(b[54:58]) == 0xff0000 && readUint32(b[58:62]) == 0xff00 &&
|
||||||
|
|
@ -182,16 +187,16 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b
|
||||||
compression = 0
|
compression = 0
|
||||||
}
|
}
|
||||||
if planes != 1 || compression != 0 {
|
if planes != 1 || compression != 0 {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
switch bpp {
|
switch bpp {
|
||||||
case 8:
|
case 8:
|
||||||
if offset != fileHeaderLen+infoLen+256*4 {
|
if offset != fileHeaderLen+infoLen+256*4 {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
_, err = io.ReadFull(r, b[:256*4])
|
_, err = io.ReadFull(r, b[:256*4])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return image.Config{}, 0, false, err
|
return image.Config{}, 0, false, false, err
|
||||||
}
|
}
|
||||||
pcm := make(color.Palette, 256)
|
pcm := make(color.Palette, 256)
|
||||||
for i := range pcm {
|
for i := range pcm {
|
||||||
|
|
@ -199,19 +204,40 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b
|
||||||
// Every 4th byte is padding.
|
// Every 4th byte is padding.
|
||||||
pcm[i] = color.RGBA{b[4*i+2], b[4*i+1], b[4*i+0], 0xFF}
|
pcm[i] = color.RGBA{b[4*i+2], b[4*i+1], b[4*i+0], 0xFF}
|
||||||
}
|
}
|
||||||
return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, nil
|
return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, false, nil
|
||||||
case 24:
|
case 24:
|
||||||
if offset != fileHeaderLen+infoLen {
|
if offset != fileHeaderLen+infoLen {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, nil
|
return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, false, nil
|
||||||
case 32:
|
case 32:
|
||||||
if offset != fileHeaderLen+infoLen {
|
if offset != fileHeaderLen+infoLen {
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, nil
|
// 32 bits per pixel is possibly RGBX (X is padding) or RGBA (A is
|
||||||
|
// alpha transparency). However, for BMP images, "Alpha is a
|
||||||
|
// poorly-documented and inconsistently-used feature" says
|
||||||
|
// https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc;l=621
|
||||||
|
//
|
||||||
|
// That goes on to say "BITMAPV3HEADER+ have an alpha bitmask in the
|
||||||
|
// info header... so we respect it at all times... [For earlier
|
||||||
|
// (smaller) headers we] ignore alpha in Windows V3 BMPs except inside
|
||||||
|
// ICO files".
|
||||||
|
//
|
||||||
|
// "Ignore" means to always set alpha to 0xFF (fully opaque):
|
||||||
|
// https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.h;l=272
|
||||||
|
//
|
||||||
|
// Confusingly, "Windows V3" does not correspond to BITMAPV3HEADER, but
|
||||||
|
// instead corresponds to the earlier (smaller) BITMAPINFOHEADER:
|
||||||
|
// https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc;l=258
|
||||||
|
//
|
||||||
|
// This Go package does not support ICO files and the (infoLen >
|
||||||
|
// infoHeaderLen) condition distinguishes BITMAPINFOHEADER (40 bytes)
|
||||||
|
// vs later (larger) headers.
|
||||||
|
allowAlpha = infoLen > infoHeaderLen
|
||||||
|
return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, allowAlpha, nil
|
||||||
}
|
}
|
||||||
return image.Config{}, 0, false, ErrUnsupported
|
return image.Config{}, 0, false, false, ErrUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
6
vendor/golang.org/x/image/tiff/lzw/reader.go
generated
vendored
6
vendor/golang.org/x/image/tiff/lzw/reader.go
generated
vendored
|
|
@ -3,8 +3,8 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package lzw implements the Lempel-Ziv-Welch compressed data format,
|
// Package lzw implements the Lempel-Ziv-Welch compressed data format,
|
||||||
// described in T. A. Welch, ``A Technique for High-Performance Data
|
// described in T. A. Welch, “A Technique for High-Performance Data
|
||||||
// Compression'', Computer, 17(6) (June 1984), pp 8-19.
|
// Compression”, Computer, 17(6) (June 1984), pp 8-19.
|
||||||
//
|
//
|
||||||
// In particular, it implements LZW as used by the TIFF file format, including
|
// In particular, it implements LZW as used by the TIFF file format, including
|
||||||
// an "off by one" algorithmic difference when compared to standard LZW.
|
// an "off by one" algorithmic difference when compared to standard LZW.
|
||||||
|
|
@ -30,7 +30,7 @@ Aldus "off by one" algorithm.
|
||||||
|
|
||||||
The Go code doesn't read (invalid) TIFF files written by old versions of
|
The Go code doesn't read (invalid) TIFF files written by old versions of
|
||||||
libtiff, but the LZW algorithm in this package still differs from the one in
|
libtiff, but the LZW algorithm in this package still differs from the one in
|
||||||
Go's standard package library to accomodate this "off by one" in valid TIFFs.
|
Go's standard package library to accommodate this "off by one" in valid TIFFs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
57
vendor/golang.org/x/image/tiff/reader.go
generated
vendored
57
vendor/golang.org/x/image/tiff/reader.go
generated
vendored
|
|
@ -38,6 +38,52 @@ func (e UnsupportedError) Error() string {
|
||||||
|
|
||||||
var errNoPixels = FormatError("not enough pixel data")
|
var errNoPixels = FormatError("not enough pixel data")
|
||||||
|
|
||||||
|
const maxChunkSize = 10 << 20 // 10M
|
||||||
|
|
||||||
|
// safeReadtAt is a verbatim copy of internal/saferio.ReadDataAt from the
|
||||||
|
// standard library, which is used to read data from a reader using a length
|
||||||
|
// provided by untrusted data, without allocating the entire slice ahead of time
|
||||||
|
// if it is large (>maxChunkSize). This allows us to avoid allocating giant
|
||||||
|
// slices before learning that we can't actually read that much data from the
|
||||||
|
// reader.
|
||||||
|
func safeReadAt(r io.ReaderAt, n uint64, off int64) ([]byte, error) {
|
||||||
|
if int64(n) < 0 || n != uint64(int(n)) {
|
||||||
|
// n is too large to fit in int, so we can't allocate
|
||||||
|
// a buffer large enough. Treat this as a read failure.
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if n < maxChunkSize {
|
||||||
|
buf := make([]byte, n)
|
||||||
|
_, err := r.ReadAt(buf, off)
|
||||||
|
if err != nil {
|
||||||
|
// io.SectionReader can return EOF for n == 0,
|
||||||
|
// but for our purposes that is a success.
|
||||||
|
if err != io.EOF || n > 0 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf []byte
|
||||||
|
buf1 := make([]byte, maxChunkSize)
|
||||||
|
for n > 0 {
|
||||||
|
next := n
|
||||||
|
if next > maxChunkSize {
|
||||||
|
next = maxChunkSize
|
||||||
|
}
|
||||||
|
_, err := r.ReadAt(buf1[:next], off)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
buf = append(buf, buf1[:next]...)
|
||||||
|
n -= next
|
||||||
|
off += int64(next)
|
||||||
|
}
|
||||||
|
return buf, nil
|
||||||
|
}
|
||||||
|
|
||||||
type decoder struct {
|
type decoder struct {
|
||||||
r io.ReaderAt
|
r io.ReaderAt
|
||||||
byteOrder binary.ByteOrder
|
byteOrder binary.ByteOrder
|
||||||
|
|
@ -82,8 +128,7 @@ func (d *decoder) ifdUint(p []byte) (u []uint, err error) {
|
||||||
}
|
}
|
||||||
if datalen := lengths[datatype] * count; datalen > 4 {
|
if datalen := lengths[datatype] * count; datalen > 4 {
|
||||||
// The IFD contains a pointer to the real value.
|
// The IFD contains a pointer to the real value.
|
||||||
raw = make([]byte, datalen)
|
raw, err = safeReadAt(d.r, uint64(datalen), int64(d.byteOrder.Uint32(p[8:12])))
|
||||||
_, err = d.r.ReadAt(raw, int64(d.byteOrder.Uint32(p[8:12])))
|
|
||||||
} else {
|
} else {
|
||||||
raw = p[8 : 8+datalen]
|
raw = p[8 : 8+datalen]
|
||||||
}
|
}
|
||||||
|
|
@ -427,8 +472,9 @@ func newDecoder(r io.Reader) (*decoder, error) {
|
||||||
numItems := int(d.byteOrder.Uint16(p[0:2]))
|
numItems := int(d.byteOrder.Uint16(p[0:2]))
|
||||||
|
|
||||||
// All IFD entries are read in one chunk.
|
// All IFD entries are read in one chunk.
|
||||||
p = make([]byte, ifdLen*numItems)
|
var err error
|
||||||
if _, err := d.r.ReadAt(p, ifdOffset+2); err != nil {
|
p, err = safeReadAt(d.r, uint64(ifdLen*numItems), ifdOffset+2)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -656,8 +702,7 @@ func Decode(r io.Reader) (img image.Image, err error) {
|
||||||
if b, ok := d.r.(*buffer); ok {
|
if b, ok := d.r.(*buffer); ok {
|
||||||
d.buf, err = b.Slice(int(offset), int(n))
|
d.buf, err = b.Slice(int(offset), int(n))
|
||||||
} else {
|
} else {
|
||||||
d.buf = make([]byte, n)
|
d.buf, err = safeReadAt(d.r, uint64(n), offset)
|
||||||
_, err = d.r.ReadAt(d.buf, offset)
|
|
||||||
}
|
}
|
||||||
case cG3:
|
case cG3:
|
||||||
inv := d.firstVal(tPhotometricInterpretation) == pWhiteIsZero
|
inv := d.firstVal(tPhotometricInterpretation) == pWhiteIsZero
|
||||||
|
|
|
||||||
3
vendor/golang.org/x/image/tiff/writer.go
generated
vendored
3
vendor/golang.org/x/image/tiff/writer.go
generated
vendored
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -338,6 +339,8 @@ func Encode(w io.Writer, m image.Image, opt *Options) error {
|
||||||
}
|
}
|
||||||
case cDeflate:
|
case cDeflate:
|
||||||
dst = zlib.NewWriter(&buf)
|
dst = zlib.NewWriter(&buf)
|
||||||
|
default:
|
||||||
|
return errors.New("tiff: unsupported compression")
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := uint32(prNone)
|
pr := uint32(prNone)
|
||||||
|
|
|
||||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
|
@ -406,7 +406,7 @@ go.uber.org/atomic
|
||||||
golang.org/x/crypto/bcrypt
|
golang.org/x/crypto/bcrypt
|
||||||
golang.org/x/crypto/blowfish
|
golang.org/x/crypto/blowfish
|
||||||
golang.org/x/crypto/ssh/terminal
|
golang.org/x/crypto/ssh/terminal
|
||||||
# golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
# golang.org/x/image v0.5.0
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
golang.org/x/image/bmp
|
golang.org/x/image/bmp
|
||||||
golang.org/x/image/ccitt
|
golang.org/x/image/ccitt
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue