From 81d6040bebc240b159ebc2082cd0bf463da5bb46 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 30 Jul 2023 17:32:54 -0400 Subject: [PATCH] fix: skip files that attempt to break filesystem (#3238) --- brut.j.dir/src/main/java/brut/directory/DirUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/brut.j.dir/src/main/java/brut/directory/DirUtil.java b/brut.j.dir/src/main/java/brut/directory/DirUtil.java index e36a93b211..bfc1e0a1e3 100644 --- a/brut.j.dir/src/main/java/brut/directory/DirUtil.java +++ b/brut.j.dir/src/main/java/brut/directory/DirUtil.java @@ -23,6 +23,7 @@ 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 static void copyToDir(Directory in, File out, String fileName) 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); } }