1
0
mirror of https://github.com/golang/go synced 2024-11-12 01:10:21 -07:00

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 <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
LE Manh Cuong 2019-01-05 23:39:24 +07:00 committed by Brad Fitzpatrick
parent 11847cb8e0
commit f7248ba753

View File

@ -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) {