You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Zip4j 2.11.5
Windows 10 (but might apply to Linux as well)
Description
When extracting a ZIP which contains an entry named ., Zip4j deletes the output directory before eventually throwing an exception. This is unexpected and looks like a bug. Zip4j should not delete the output directory, instead the user code should do that, if desired.
The underlying issue seems to be that Zip4j does not ignore an entry named . (respectively throw an exception) but instead treats it as regular file and tries to write to it. However, because it points to the existing output directory, trying to open the directory as file fails. Zip4j then erroneously tries to perform clean-up and actually deletes the directory here:
Note: This actually applies to more than just the literal string ., for example also to . (with trailing space). So to detect this is might be best to check the result of getCanonicalPath(), or to adjust AbstractExtractFileTask#unzipFile to fail fast if outputFile is an existing directory (and not try to delete it).
Version
Zip4j 2.11.5
Windows 10 (but might apply to Linux as well)
Description
When extracting a ZIP which contains an entry named
.
, Zip4j deletes the output directory before eventually throwing an exception. This is unexpected and looks like a bug. Zip4j should not delete the output directory, instead the user code should do that, if desired.The underlying issue seems to be that Zip4j does not ignore an entry named
.
(respectively throw an exception) but instead treats it as regular file and tries to write to it. However, because it points to the existing output directory, trying to open the directory as file fails. Zip4j then erroneously tries to perform clean-up and actually deletes the directory here:zip4j/src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java
Lines 114 to 117 in c4c993c
Note: This actually applies to more than just the literal string
.
, for example also to.
(with trailing space). So to detect this is might be best to check the result ofgetCanonicalPath()
, or to adjustAbstractExtractFileTask#unzipFile
to fail fast ifoutputFile
is an existing directory (and not try to delete it).Example code
This will unexpectedly print
The text was updated successfully, but these errors were encountered: