Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sleuthkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Sleuthkit
Commits
4aa94542
Commit
4aa94542
authored
6 years ago
by
Ann Priestman
Browse files
Options
Downloads
Patches
Plain Diff
Test that the image handle is still valid before using it.
parent
12a3be88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+28
-2
28 additions, 2 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
with
28 additions
and
2 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+
28
−
2
View file @
4aa94542
...
...
@@ -643,6 +643,9 @@ private static long openImage(String[] imageFiles, int sSize, boolean useCache)
public
static
long
openVs
(
long
imgHandle
,
long
vsOffset
)
throws
TskCoreException
{
getTSKReadLock
();
try
{
if
(!
imgHandleIsValid
(
imgHandle
))
{
throw
new
TskCoreException
(
"Image handle "
+
imgHandle
+
" is closed"
);
}
return
openVsNat
(
imgHandle
,
vsOffset
);
}
finally
{
releaseTSKReadLock
();
...
...
@@ -756,6 +759,17 @@ private static int convertSignedToUnsigned(int val) {
return
val
&
0xffff
;
// convert negative value to positive value
}
/**
* Test that the given image handle is valid.
* @param imgHandle
* @return true if it is valid, false otherwise
*/
private
static
boolean
imgHandleIsValid
(
long
imgHandle
)
{
synchronized
(
HandleCache
.
cacheLock
)
{
return
HandleCache
.
fsHandleCache
.
containsKey
(
imgHandle
);
}
}
//do reads
/**
...
...
@@ -775,6 +789,9 @@ private static int convertSignedToUnsigned(int val) {
public
static
int
readImg
(
long
imgHandle
,
byte
[]
readBuffer
,
long
offset
,
long
len
)
throws
TskCoreException
{
getTSKReadLock
();
try
{
if
(!
imgHandleIsValid
(
imgHandle
))
{
throw
new
TskCoreException
(
"Image handle "
+
imgHandle
+
" is closed"
);
}
//returned byte[] is the data buffer
return
readImgNat
(
imgHandle
,
readBuffer
,
offset
,
len
);
}
finally
{
...
...
@@ -1226,6 +1243,9 @@ private static String timezoneLongToShort(String timezoneLongForm) {
public
static
int
finishImageWriter
(
long
imgHandle
)
throws
TskCoreException
{
getTSKReadLock
();
try
{
if
(!
imgHandleIsValid
(
imgHandle
))
{
throw
new
TskCoreException
(
"Image handle "
+
imgHandle
+
" is closed"
);
}
return
finishImageWriterNat
(
imgHandle
);
}
finally
{
releaseTSKReadLock
();
...
...
@@ -1242,7 +1262,11 @@ public static int finishImageWriter(long imgHandle) throws TskCoreException {
public
static
int
getFinishImageProgress
(
long
imgHandle
)
{
getTSKReadLock
();
try
{
return
getFinishImageProgressNat
(
imgHandle
);
if
(
imgHandleIsValid
(
imgHandle
))
{
return
getFinishImageProgressNat
(
imgHandle
);
}
else
{
return
0
;
}
}
finally
{
releaseTSKReadLock
();
}
...
...
@@ -1256,7 +1280,9 @@ public static int getFinishImageProgress(long imgHandle) {
public
static
void
cancelFinishImage
(
long
imgHandle
)
{
getTSKReadLock
();
try
{
cancelFinishImageNat
(
imgHandle
);
if
(
imgHandleIsValid
(
imgHandle
))
{
cancelFinishImageNat
(
imgHandle
);
}
}
finally
{
releaseTSKReadLock
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment