Skip to content

Commit 8e00808

Browse files
committed
Stash normalized path outside of loop
1 parent 9002a66 commit 8e00808

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/org/labkey/test/TestFileUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,13 @@ private static List<File> unTar(final File inputFile, final File outputDir) thro
632632
TarArchiveInputStream inputStream = new ArchiveStreamFactory().createArchiveInputStream("tar", is))
633633
{
634634
TarArchiveEntry entry;
635+
Path normalizedOutputPath = outputDir.toPath().normalize();
636+
635637
while ((entry = inputStream.getNextEntry()) != null)
636638
{
637639
final File outputFile = new File(outputDir, entry.getName());
638640

639-
if (!outputFile.toPath().normalize().startsWith(outputDir.toPath()))
641+
if (!outputFile.toPath().normalize().startsWith(normalizedOutputPath))
640642
throw new IOException("Bad zip entry (" + entry.getName() + ") in " + inputFile.getAbsolutePath());
641643

642644
if (entry.isDirectory())

0 commit comments

Comments
 (0)