Skip to content

archive/zip: Error extracting large ZIP files created by Windows10 built-in ZIP tool #74993

Description

@luotianqi777

Go version

1.23.0

Output of go env in your module/workspace:

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\XJ\AppData\Local\go-build
set GOENV=C:\Users\XJ\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=gitlab.cd.anpro
set GOMODCACHE=C:\Users\XJ\go\pkg\mod
set GONOPROXY=gitlab.cd.anpro
set GONOSUMDB=gitlab.cd.anpro
set GOOS=windows
set GOPATH=C:\Users\XJ\go
set GOPRIVATE=gitlab.cd.anpro
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64   
set GOVCS=
set GOVERSION=go1.23.0
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\XJ\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=F:\Project\GO\common\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\XJ\AppData\Local\Temp\go-build135844245=/tmp/go-build -gno-record-gcc-switches\

What did you do?

When trying to extract a large ZIP archive (several GB in size) created using the Windows 10 built-in "Send to → Compressed (zipped) folder" feature, the extraction fails with an error related to the central directory.

Steps to reproduce:

  1. On Windows 10, right-click a large folder (>4GB total) → "Send to → Compressed (zipped) folder".
  2. Try to extract the resulting .zip with this library in Go.
  3. Observe the extraction error regarding the central directory.

example code:

	f, _ := os.Open("./test/zip-big.zip")
	defer f.Close()
	stat, _ := f.Stat()
	fmt.Println("Size:", stat.Size())
	_, err := zip.NewReader(f, stat.Size())
	fmt.Println("zip open:", err)

What did you see happen?

The same archive can be opened by Windows Explorer, 7-Zip, and WinRAR without issues, but fails when using this library. It seems the built-in ZIP tool generates a non-standard or incomplete central directory (possibly ZIP64) that causes compatibility problems.

example out:

Size: 4531791165
zip open: zip: not a valid zip file

What did you expect to see?

The library should be able to extract ZIP files created by the Windows built-in tool, even for large archives.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FrozenDueToAge

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions