Skip to content
Snippets Groups Projects
Unverified Commit d77a53be authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #1078 from dgrove727/3435_InvalidPathTSK

3435 invalid path tsk
parents 8eeb63a4 e51bd3d8
No related branches found
No related tags found
No related merge requests found
/* /*
* SleuthKit Java Bindings * SleuthKit Java Bindings
* *
* Copyright 2011-2017 Basis Technology Corp. * Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
...@@ -82,8 +82,8 @@ public abstract class AbstractFile extends AbstractContent { ...@@ -82,8 +82,8 @@ public abstract class AbstractFile extends AbstractContent {
private boolean md5HashDirty = false; private boolean md5HashDirty = false;
private String mimeType; private String mimeType;
private boolean mimeTypeDirty = false; private boolean mimeTypeDirty = false;
private static final Logger logger = Logger.getLogger(AbstractFile.class.getName()); private static final Logger LOGGER = Logger.getLogger(AbstractFile.class.getName());
private static final ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle"); private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
private long dataSourceObjectId; private long dataSourceObjectId;
private final String extension; private final String extension;
...@@ -801,7 +801,7 @@ protected int readInt(byte[] buf, long offset, long len) throws TskCoreException ...@@ -801,7 +801,7 @@ protected int readInt(byte[] buf, long offset, long len) throws TskCoreException
protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreException { protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreException {
if (!localPathSet) { if (!localPathSet) {
throw new TskCoreException( throw new TskCoreException(
bundle.getString("AbstractFile.readLocal.exception.msg1.text")); BUNDLE.getString("AbstractFile.readLocal.exception.msg1.text"));
} }
if (isDir()) { if (isDir()) {
...@@ -811,11 +811,11 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE ...@@ -811,11 +811,11 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE
loadLocalFile(); loadLocalFile();
if (!localFile.exists()) { if (!localFile.exists()) {
throw new TskCoreException( throw new TskCoreException(
MessageFormat.format(bundle.getString("AbstractFile.readLocal.exception.msg2.text"), localAbsPath)); MessageFormat.format(BUNDLE.getString("AbstractFile.readLocal.exception.msg2.text"), localAbsPath));
} }
if (!localFile.canRead()) { if (!localFile.canRead()) {
throw new TskCoreException( throw new TskCoreException(
MessageFormat.format(bundle.getString("AbstractFile.readLocal.exception.msg3.text"), localAbsPath)); MessageFormat.format(BUNDLE.getString("AbstractFile.readLocal.exception.msg3.text"), localAbsPath));
} }
int bytesRead = 0; int bytesRead = 0;
...@@ -826,10 +826,10 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE ...@@ -826,10 +826,10 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE
try { try {
localFileHandle = new RandomAccessFile(localFile, "r"); localFileHandle = new RandomAccessFile(localFile, "r");
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
final String msg = MessageFormat.format(bundle.getString( final String msg = MessageFormat.format(BUNDLE.getString(
"AbstractFile.readLocal.exception.msg4.text"), "AbstractFile.readLocal.exception.msg4.text"),
localAbsPath); localAbsPath);
logger.log(Level.SEVERE, msg, ex); LOGGER.log(Level.SEVERE, msg, ex);
//file could have been deleted or moved //file could have been deleted or moved
throw new TskCoreException(msg, ex); throw new TskCoreException(msg, ex);
} }
...@@ -863,8 +863,8 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE ...@@ -863,8 +863,8 @@ protected final int readLocal(byte[] buf, long offset, long len) throws TskCoreE
return localFileHandle.read(buf, 0, (int) len); return localFileHandle.read(buf, 0, (int) len);
} }
} catch (IOException ex) { } catch (IOException ex) {
final String msg = MessageFormat.format(bundle.getString("AbstractFile.readLocal.exception.msg5.text"), localAbsPath); final String msg = MessageFormat.format(BUNDLE.getString("AbstractFile.readLocal.exception.msg5.text"), localAbsPath);
logger.log(Level.SEVERE, msg, ex); LOGGER.log(Level.SEVERE, msg, ex);
//local file could have been deleted / moved //local file could have been deleted / moved
throw new TskCoreException(msg, ex); throw new TskCoreException(msg, ex);
} }
...@@ -937,7 +937,7 @@ public boolean exists() { ...@@ -937,7 +937,7 @@ public boolean exists() {
loadLocalFile(); loadLocalFile();
return localFile.exists(); return localFile.exists();
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, ex.getMessage()); LOGGER.log(Level.SEVERE, ex.getMessage());
return false; return false;
} }
} }
...@@ -958,7 +958,7 @@ public boolean canRead() { ...@@ -958,7 +958,7 @@ public boolean canRead() {
loadLocalFile(); loadLocalFile();
return localFile.canRead(); return localFile.canRead();
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, ex.getMessage()); LOGGER.log(Level.SEVERE, ex.getMessage());
return false; return false;
} }
} }
...@@ -973,7 +973,7 @@ public boolean canRead() { ...@@ -973,7 +973,7 @@ public boolean canRead() {
private void loadLocalFile() throws TskCoreException { private void loadLocalFile() throws TskCoreException {
if (!localPathSet) { if (!localPathSet) {
throw new TskCoreException( throw new TskCoreException(
bundle.getString("AbstractFile.readLocal.exception.msg1.text")); BUNDLE.getString("AbstractFile.readLocal.exception.msg1.text"));
} }
// already been set // already been set
...@@ -998,7 +998,7 @@ public void close() { ...@@ -998,7 +998,7 @@ public void close() {
try { try {
localFileHandle.close(); localFileHandle.close();
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.SEVERE, "Could not close file handle for file: " + getParentPath() + "/" + getName(), ex); //NON-NLS LOGGER.log(Level.SEVERE, "Could not close file handle for file: " + getParentPath() + getName(), ex); //NON-NLS
} }
localFileHandle = null; localFileHandle = null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment