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

SrgMcpRenamer may throw "ZipException: invalid entry compressed size" #3

Open
phantamanta44 opened this issue Dec 30, 2020 · 0 comments

Comments

@phantamanta44
Copy link

In SrgMcpRenamer, it is possible for the last case in the zip copying function to throw a ZipException: invalid entry compressed size:

zout.putNextEntry(ein);
Utils.copy(zin, zout);

The stack trace might look like this, which is what I get when I try to use the dependency curse.maven:tinkers-tool-leveling-250957:2630860:

Exception in thread "main" java.util.zip.ZipException: invalid entry compressed size (expected 256 but got 257 bytes)
	at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:267)
	at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:192)
	at net.minecraftforge.installertools.SrgMcpRenamer.process(SrgMcpRenamer.java:155)
	at net.minecraftforge.installertools.ConsoleTool.main(ConsoleTool.java:55)
	Suppressed: java.util.zip.ZipException: invalid entry compressed size (expected 256 but got 257 bytes)
		at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:267)
		at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:360)
		at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238)
		at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:377)
		at net.minecraftforge.installertools.SrgMcpRenamer.process(SrgMcpRenamer.java:159)
		... 1 more

This happens because it's possible for slight discrepancies to arise between the compressed size of a file in the original archive and the mapped one, but since the code just straight up copies over the exact same ZipEntry instance, the discrepancy is noticed by ZipOutputStream, which assumes it's an error and raises this exception. A fix might be simply to create a new ZipEntry (as is done in the other cases) and to populate all the fields manually, so the new compressed size is computed automatically.

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

No branches or pull requests

1 participant