Skip to content
Permalink
Browse files
zipslip
nosan committed Sep 10, 2022
1 parent 514fbbb commit dcc5818d80489d3ebc2ed4265d673bc05af08551
Showing 1 changed file with 7 additions and 4 deletions.
* @param destination the directory to which to extract the files (already created)
* @throws IOException an I/O error occurs
*/
protected void extract(Path archiveFile, Path destination) throws IOException {
try (ArchiveInputStream archiveInputStream = createArchiveInputStream(archiveFile)) {

COLLECTOR-SAHAB / covering test: WebCassandraDirectoryProviderTests

archiveFile.stringValue=/tmp/junit3609700784823010961/.embedded-cassandra/cassandra/4.0.1/17902990773789247756-apache-cassandra-4.0.1-bin.tar.gz only occurs in the original version.

COLLECTOR-SAHAB / differentiating test: WebCassandraDirectoryProviderTests

archiveFile.stringValue=/tmp/junit12864293504978632419/.embedded-cassandra/cassandra/4.0.1/15673137600379097014-apache-cassandra-4.0.1-bin.tar.gz only occurs in the patched version.

ArchiveEntry entry;
while ((entry = archiveInputStream.getNextEntry()) != null) {
Path entryPath = destination.resolve(entry.getName()).normalize().toAbsolutePath();
if (!entryPath.startsWith(destination)) {
throw new IOException("Bad zip entry [" + entry.getName() + "]");
}
if (entry.isDirectory()) {
Files.createDirectories(destination.resolve(entry.getName()).normalize().toAbsolutePath());
Files.createDirectories(entryPath);
}
else {
Path file = destination.resolve(entry.getName()).normalize().toAbsolutePath();
Path parent = file.getParent();
Path parent = entryPath.getParent();
if (!Files.exists(parent)) {
Files.createDirectories(parent);
}
Files.copy(archiveInputStream, file, StandardCopyOption.REPLACE_EXISTING);
Files.copy(archiveInputStream, entryPath, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
/**

0 comments on commit dcc5818

Please sign in to comment.