From d888b7b863699ca0bbc4ea20cd67efb99774063d Mon Sep 17 00:00:00 2001 From: adam-m Date: Tue, 16 Apr 2013 15:03:26 -0400 Subject: [PATCH] scalpel class: do additional file path validation before crossing jni boundary --- .../sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java index d7d0c5c804..0edd86d448 100644 --- a/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java +++ b/ScalpelCarver/src/org/sleuthkit/autopsy/scalpel/jni/ScalpelCarver.java @@ -132,6 +132,17 @@ public class ScalpelCarver { || outputFolderPath == null || outputFolderPath.isEmpty()) { throw new ScalpelException("Invalid arguments for scalpel carving. "); } + + //validate the paths passed in + File config = new File(configFilePath); + if (! config.exists() || ! config.canRead()) { + throw new ScalpelException("Cannot read libscalpel config file: " + configFilePath); + } + + File outDir = new File(outputFolderPath); + if (! outDir.exists() || ! outDir.canWrite()) { + throw new ScalpelException("Cannot write to libscalpel output dir: " + outputFolderPath); + } final String carverInputId = file.getId() + ": " + file.getName(); final ReadContentInputStream carverInput = new ReadContentInputStream(file);