fix: skip files that attempt to break filesystem (#3238)

This commit is contained in:
Connor Tumbleson 2023-07-30 17:32:54 -04:00 committed by GitHub
parent 663088890b
commit 81d6040beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import brut.common.TraversalUnknownFileException;
import brut.util.BrutIO;
import brut.util.OS;
import java.io.*;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.util.logging.Logger;
@ -96,9 +97,11 @@ public class DirUtil {
BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath()));
}
}
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
} catch (FileSystemException exception) {
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getReason()));
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException | IOException exception) {
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage()));
} catch (IOException | BrutException ex) {
} catch (BrutException ex) {
throw new DirectoryException("Error copying file: " + fileName, ex);
}
}