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
fcf4c20e
Commit
fcf4c20e
authored
11 years ago
by
Richard Cordovano
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'sam/hashdb_sqlite' into tags_and_hashes
parents
6a8a355d
ceae7787
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
tsk/hashdb/hdb_index.cpp
+41
-18
41 additions, 18 deletions
tsk/hashdb/hdb_index.cpp
with
41 additions
and
18 deletions
tsk/hashdb/hdb_index.cpp
+
41
−
18
View file @
fcf4c20e
...
...
@@ -554,6 +554,38 @@ void tsk_idx_clear(TSK_HDB_INFO * hdb_info)
}
}
/**
* \ingroup hashdblib
* Remove old indices.
*
* @param hdb_info Hash database to consider
* @param htype Hash type that index should be of
*
* @return 0 if success; 1 if failed
*/
uint8_t
tsk_hdb_delete_old
(
TSK_HDB_INFO
*
hdb_info
)
{
// Call setup to populate the idx_info struct so we can get the filename
hdb_setupindex
(
hdb_info
,
hdb_info
->
hash_type
,
0
);
// If idx_info is null then there isn't an index
if
(
hdb_info
->
idx_info
!=
NULL
)
{
char
cfname
[
1024
];
snprintf
(
cfname
,
1024
,
"%"
PRIttocTSK
,
hdb_info
->
idx_info
->
idx_fname
);
// Now that we have a filename, close out all index stuff.
tsk_idx_clear
(
hdb_info
);
if
(
cfname
!=
""
)
{
//attempt to delete the old index file
if
(
remove
(
cfname
)
!=
0
)
{
return
1
;
//error
}
}
}
return
0
;
}
/**
* \ingroup hashdblib
...
...
@@ -572,7 +604,7 @@ tsk_hdb_regenerate_index(TSK_HDB_INFO * hdb_info, TSK_TCHAR * db_type, uint8_t o
// Set the hash type since that will affect the filename for legacy indices
char
c_db_type
[
32
];
snprintf
(
c_db_type
,
32
,
"%"
PRIttocTSK
,
db_type
);
TSK_HDB_HTYPE_ENUM
h
type
=
TSK_HDB_HTYPE_MD5_ID
;
hdb_info
->
hash_
type
=
TSK_HDB_HTYPE_MD5_ID
;
if
(
strcmp
(
c_db_type
,
TSK_HDB_DBTYPE_NSRL_MD5_STR
)
==
0
)
{
hdb_info
->
hash_type
=
TSK_HDB_HTYPE_MD5_ID
;
}
else
if
(
strcmp
(
c_db_type
,
TSK_HDB_DBTYPE_NSRL_SHA1_STR
)
==
0
)
{
...
...
@@ -584,25 +616,16 @@ tsk_hdb_regenerate_index(TSK_HDB_INFO * hdb_info, TSK_TCHAR * db_type, uint8_t o
}
else
if
(
strcmp
(
c_db_type
,
TSK_HDB_DBTYPE_ENCASE_STR
)
==
0
)
{
hdb_info
->
hash_type
=
TSK_HDB_HTYPE_MD5_ID
;
}
if
(
tsk_hdb_delete_old
(
hdb_info
)
!=
0
)
{
return
0
;
//error
}
// Call setup to populate the idx_info struct so we can get the filename
hdb_setupindex
(
hdb_info
,
htype
,
0
);
// If idx_info is null then there isn't an index
if
(
hdb_info
->
idx_info
!=
NULL
)
{
char
cfname
[
1024
];
snprintf
(
cfname
,
1024
,
"%"
PRIttocTSK
,
hdb_info
->
idx_info
->
idx_fname
);
// Now that we have a filename, close out all index stuff.
tsk_idx_clear
(
hdb_info
);
if
(
cfname
!=
""
)
{
//attempt to delete the old index file
if
(
remove
(
cfname
)
!=
0
)
{
return
0
;
//error
}
}
// Run a second pass in case there were two indices
if
(
tsk_hdb_delete_old
(
hdb_info
)
!=
0
)
{
return
0
;
//error
}
}
else
{
// Close index stuff before trying to create a new one.
tsk_idx_clear
(
hdb_info
);
...
...
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