Skip to content

Commit 2993e68

Browse files
trgpawilkinsona
authored andcommitted
Prevent extracting zip entries outside of destination path
See gh-25505
1 parent da3920b commit 2993e68

File tree

1 file changed

+1
-1
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools

1 file changed

+1
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/ExtractCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected void run(Map<Option, String> options, List<String> parameters) {
8888
private void write(ZipInputStream zip, ZipEntry entry, File destination) throws IOException {
8989
String path = StringUtils.cleanPath(entry.getName());
9090
File file = new File(destination, path);
91-
if (file.getAbsolutePath().startsWith(destination.getAbsolutePath())) {
91+
if (file.getCanonicalPath().startsWith(destination.getCanonicalPath() + File.separator)) {
9292
mkParentDirs(file);
9393
try (OutputStream out = new FileOutputStream(file)) {
9494
StreamUtils.copy(zip, out);

0 commit comments

Comments
 (0)