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

AbstractReader.Skip doesn't work for UsePostDataDescriptor zip streams #162

Closed
AlexVallat opened this issue Aug 12, 2016 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@AlexVallat
Copy link

In AbstractReader.Skip() the shortcut to skip data by reading the raw stream rather than decompressing doesn't work if .CompressedSize is 0 due to a UsePostDataDescriptor formatted zip entry header.

@adamhathcock
Copy link
Owner

It might be related to the thing you just fixed but that was me skipping data start position.

Anyway, if the descriptor doesn't put in a compressed size I don't know how I can just skip it without decompressing.

It's possible to scan the bytes for a zip header but that doesn't feel correct anyway. Already had issues with nested archives.

@AlexVallat
Copy link
Author

I don't think you can skip it without decompressing, if the size isn't known. The problem is that it should not skip 0 bytes and assume it's skipped the contents, I think it has to use the fallback path of actually reading the contents (like it does for the Entry.IsSolid case).

@adamhathcock
Copy link
Owner

OHH...I see. It thinks it should just skip 0 bytes. Yeah, you're right it should decompress it.

Any chance of a PR for this issue?

@AlexVallat
Copy link
Author

Simplest solution I can think of is to add to the ZipEntry constructor:

if (FlagUtility.HasFlag(filePart.Header.Flags, HeaderFlags.UsePostDataDescriptor))
{
    IsSolid = true;
}

but that might be abusing the IsSolid property? I only saw it set for Rars, and only consumed in the Skip() method so this would probably be OK, but it smells a bit. Could rename the property to DecompressDuringSkip or similar, or otherwise I think it's going to take some extra plumbing.

Or alternatively you could assume that if CompressedSize was 0 it should use a decompressed skip - probably harmless as if it really is empty it won't take long to decompress it!

@adamhathcock
Copy link
Owner

I guess where IsSolid is being checked should also check for the flag header and a size of zero to trigger the decompression

@AlexVallat
Copy link
Author

Unfortunately that's in AbstractReader, and therefore doesn't have access to the ZipEntry Header - it shouldn't, in principle, have knowledge of zip-specific flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants