Skip to content

Problem extracting zip file: illegal file name that breaks out of the target directory: / #400

@Gr33nbl00d

Description

@Gr33nbl00d

Hi i have problem extracting a zip file which was generated by maven assembly plugin.

if (!outputFile.getCanonicalPath().startsWith(outputCanonicalPath)) {

I debuged into that place and found out that the outputfile does not have a trailing slash but the outputCannonical path variable has.
Thats what i see in the IDE

outputFile = {File@1809} "D:\Users\XXXXXXX\AppData\Local\Temp\dependentrules14443115985707206885"
outputCanonicalPath = "D:\Users\XXXXXXX\AppData\Local\Temp\dependentrules14443115985707206885\"

The zip file header looks like this:

versionMadeBy = 788
fileCommentLength = 0
diskNumberStart = 0
internalFileAttributes = {byte[2]@1817} [0, 0]
externalFileAttributes = {byte[4]@1818} [16, 0, -19, 65]
offsetLocalHeader = 5294
fileComment = null
versionNeededToExtract = 10
generalPurposeFlag = {byte[2]@1819} [0, 0]
compressionMethod = {CompressionMethod@1820} "STORE"
lastModifiedTime = 1412516727
crc = 0
compressedSize = 0
uncompressedSize = 0
fileNameLength = 1
extraFieldLength = 0
fileName = "/"
isEncrypted = false
encryptionMethod = {EncryptionMethod@1822} "NONE"
dataDescriptorExists = false
zip64ExtendedInfo = null
aesExtraDataRecord = null
fileNameUTF8Encoded = false
extraDataRecords = null
isDirectory = true
signature = {HeaderSignature@1823} "CENTRAL_DIRECTORY"

Any solution to this? Is this a bug? Anyone had the same problem?

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions