Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/zip: possibly useless test #28700

Open
ainar-g opened this issue Nov 9, 2018 · 3 comments

Comments

@ainar-g
Copy link
Contributor

commented Nov 9, 2018

While playing around with the new vet and its nilness check, I have found an interesting bug. In src/archive/zip/reader_test.go:985 we have a test for #10956, but the test doesn't actually check anything:

_, err := NewReader(bytes.NewReader(data), int64(len(data)))
//
if err == nil && !strings.Contains(err.Error(), want) {
	t.Errorf("error = %v; want %q", err, want)
}

It should obviously be if err != nil && … here. But when I changed it, the test failed, because it returned ErrFormat instead of the custom Errorf'd error that was expected. I ran all of the package zip's tests with -cover and the coverage profile shows that the branch in (*Reader).init is never taken.

@adg

This comment has been minimized.

Copy link
Contributor

commented May 31, 2019

It seems that fix applied for #10956 (that I reviewed and approved) wasn't actually a fix; maybe in theory, but it was never tested in practice.

As you say, the example that @dvykov provided doesn't seem to get past the readDirectoryEnd function, so the additional check added to the init method is never reached. I sent a change.

@gopherbot

This comment has been minimized.

Copy link

commented May 31, 2019

Change https://golang.org/cl/179757 mentions this issue: archive/zip: remove unused special case

@odeke-em

This comment has been minimized.

Copy link
Member

commented Jun 9, 2019

Thank you @ainar-g for the report and @adg for jumping on this and sending the fixing CL!
As per the wait-release tag added to the CL, it seems like this is punted to Go1.14. I shall update here accordingly and add the Early-In-Cycle tag too.

@odeke-em odeke-em modified the milestones: Go1.13, Go1.14 Jun 9, 2019
gopherbot pushed a commit that referenced this issue Aug 27, 2019
This removes a special case that was added to fix issue #10956, but that
was never actually effective. The code in the test case still fails to
read, so perhaps the zip64 support added in CL 6463050 inadvertently
caught this particular case.

It's possible that the original theorized bug still exists, but I'm not
convinced it was ever fixed.

Update #28700

Change-Id: I4854de616364510f64a6def30b308686563f8dbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/179757
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
tomocy added a commit to tomocy/go that referenced this issue Sep 1, 2019
This removes a special case that was added to fix issue golang#10956, but that
was never actually effective. The code in the test case still fails to
read, so perhaps the zip64 support added in CL 6463050 inadvertently
caught this particular case.

It's possible that the original theorized bug still exists, but I'm not
convinced it was ever fixed.

Update golang#28700

Change-Id: I4854de616364510f64a6def30b308686563f8dbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/179757
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
t4n6a1ka added a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
This removes a special case that was added to fix issue golang#10956, but that
was never actually effective. The code in the test case still fails to
read, so perhaps the zip64 support added in CL 6463050 inadvertently
caught this particular case.

It's possible that the original theorized bug still exists, but I'm not
convinced it was ever fixed.

Update golang#28700

Change-Id: I4854de616364510f64a6def30b308686563f8dbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/179757
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.