diff --git a/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/TransferManager.java b/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/TransferManager.java index a860286431..7523777ab5 100644 --- a/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/TransferManager.java +++ b/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/TransferManager.java @@ -1512,7 +1512,7 @@ public MultipleFileDownload downloadDirectory(String bucketName, String keyPrefi private boolean leavesRoot(File localBaseDirectory, String key) { try { - return !new File(localBaseDirectory, key).getCanonicalPath().startsWith(localBaseDirectory.getCanonicalPath()); + return !new File(localBaseDirectory, key).getCanonicalFile().toPath().startsWith(localBaseDirectory.getCanonicalFile().toPath()); } catch (IOException e) { throw new RuntimeException("Unable to canonicalize paths", e); }