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
Since this change from version 2.9.0 tot 2.9.1 the file name could still be null leading to a null pointer exception.
The validation is done in the FileHeaderFactory, but this is called from the initializeAndWriteFileHeader. As this is now after the directory check, this will never trigger:
private String validateAndGetFileName(String fileNameInZip) throws ZipException {
if (!Zip4jUtil.isStringNotNullAndNotEmpty(fileNameInZip)) {
throw new ZipException("fileNameInZip is null or empty");
} else {
return fileNameInZip;
}
}
Problematic code, 2e line is the problem when file name is null:
ZipParameters clonedZipParameters = new ZipParameters(zipParameters);
if (isZipEntryDirectory(zipParameters.getFileNameInZip())) {
clonedZipParameters.setWriteExtendedLocalFileHeader(false);
clonedZipParameters.setCompressionMethod(CompressionMethod.STORE);
clonedZipParameters.setEncryptFiles(false);
}
initializeAndWriteFileHeader(clonedZipParameters);
There are multiple solutions to solve this. Moving the validation to an earlier point or making sure there is no null pointer exception by checking if it's not null.
The text was updated successfully, but these errors were encountered:
Since this change from version 2.9.0 tot 2.9.1 the file name could still be null leading to a null pointer exception.
The validation is done in the
FileHeaderFactory
, but this is called from theinitializeAndWriteFileHeader
. As this is now after the directory check, this will never trigger:Problematic code, 2e line is the problem when file name is null:
There are multiple solutions to solve this. Moving the validation to an earlier point or making sure there is no null pointer exception by checking if it's not null.
The text was updated successfully, but these errors were encountered: