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

Jars built using `JarBuilder` do not mark directories properly #1790

shs96c opened this issue Mar 2, 2018 · 1 comment

Jars built using `JarBuilder` do not mark directories properly #1790

shs96c opened this issue Mar 2, 2018 · 1 comment


Copy link

@shs96c shs96c commented Mar 2, 2018

Steps to reproduce (in Buck's own source):

buck build src/com/facebook/buck/io
zipinfo buck-out/gen/src/com/facebook/buck/io/lib__io__output/io.jar | head -3

Expected output:
The META-INF entry is marked not only as META-INF/, but zipinfo should also indicate that it's a directory. Ideally, this directory would be user, group, and world readable and executable.

Actual output:

Archive:  buck-out/gen/src/com/facebook/buck/io/lib__io__output/io.jar
Zip file size: 15960 bytes, number of entries: 20
-rw----     2.0 fat        0 bl defN 85-Feb-01 00:00 META-INF/

The directory is not marked as a directory in the zip entry extended attributes, and is not marked as executable, meaning that if the user unpacks the directory they won't be able to cd into it.

Copy link

@sbalabanov-zz sbalabanov-zz commented Jun 21, 2018

Why should it have the unix attribute? I do not believe Jar specification requires that.
The problem is, if we write Unix attributes to jar archive, then Buck also sets the minimum version required to unpack the zip to be unx:

requiredExtractVersion |= (3 << 8);

This can potentially break other scenarios. Each ZIP implementation may read this field and act accordingly, for example, refuse to decompress.
Java itself detects that entry is a directory only by looking to a trailing slash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants