From 4dbb2ac38d8e00f72d54d184cf9bf39309e092a9 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Mon, 17 Jun 2019 19:22:27 +0200 Subject: [PATCH] Fix 32 bit builds (#129) --- .travis.yml | 1 + fse/compress.go | 2 +- fse/fse.go | 2 +- zstd/frameenc.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7973bc852a..c3fddda7f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ script: - go test -cpu=2 -tags=noasm ./... - go test -cpu=1,2,4 -short -race ./... - go test -cpu=2,4 -short -race -tags=noasm ./... + - GOOS=linux GOARCH=386 go install ./... matrix: allow_failures: diff --git a/fse/compress.go b/fse/compress.go index a0d16ea977..b69237c9b8 100644 --- a/fse/compress.go +++ b/fse/compress.go @@ -19,7 +19,7 @@ func Compress(in []byte, s *Scratch) ([]byte, error) { if len(in) <= 1 { return nil, ErrIncompressible } - if len(in) >= 2<<30 { + if len(in) > (2<<30)-1 { return nil, errors.New("input too big, must be < 2GB") } s, err := s.prepare(in) diff --git a/fse/fse.go b/fse/fse.go index 490e6806a3..075357b5b1 100644 --- a/fse/fse.go +++ b/fse/fse.go @@ -127,7 +127,7 @@ func (s *Scratch) prepare(in []byte) (*Scratch, error) { s.br.init(in) if s.DecompressLimit == 0 { // Max size 2GB. - s.DecompressLimit = 2 << 30 + s.DecompressLimit = (2 << 30) - 1 } return s, nil diff --git a/zstd/frameenc.go b/zstd/frameenc.go index 4da4e64f89..acac325275 100644 --- a/zstd/frameenc.go +++ b/zstd/frameenc.go @@ -105,7 +105,7 @@ func skippableFrame(dst []byte, total int, r io.Reader) ([]byte, error) { if total < skippableFrameHeader { return dst, fmt.Errorf("requested skippable frame (%d) < 8", total) } - if total > math.MaxUint32 { + if int64(total) > math.MaxUint32 { return dst, fmt.Errorf("requested skippable frame (%d) > max uint32", total) } dst = append(dst, 0x50, 0x2a, 0x4d, 0x18)