From f7248ba75321ace8e76f9723e9ef3badea2bdd4d Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Sat, 5 Jan 2019 23:39:24 +0700 Subject: [PATCH] archive/zip: fix casting overflow on 32-bit arch Fixes #29555 Change-Id: Ia3c0dd65bcf94dea3f6e04c23c1fe5d6d0b2c1e9 Reviewed-on: https://go-review.googlesource.com/c/156399 Run-TryBot: Brad Fitzpatrick Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/archive/zip/zip_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/archive/zip/zip_test.go b/src/archive/zip/zip_test.go index 50218a2bbd..3d5c759851 100644 --- a/src/archive/zip/zip_test.go +++ b/src/archive/zip/zip_test.go @@ -159,7 +159,7 @@ func (r *rleBuffer) Write(p []byte) (n int, err error) { return len(p), nil } -func min(x, y int) int { +func min(x, y int64) int64 { if x < y { return x } @@ -190,7 +190,7 @@ func (r *rleBuffer) ReadAt(p []byte, off int64) (n int, err error) { if len(parts) > 0 { skipBytes := off - parts[0].off for _, part := range parts { - repeat := min(int(part.n-skipBytes), len(p)-n) + repeat := int(min(part.n-skipBytes, int64(len(p)-n))) memset(p[n:n+repeat], part.b) n += repeat if n == len(p) {