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
a8cd0103
Commit
a8cd0103
authored
11 years ago
by
Samuel H. Kenyon
Browse files
Options
Downloads
Patches
Plain Diff
Update the current hash type when doing a lookup.
parent
269ff7f0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tsk/hashdb/hdb_index.cpp
+35
-19
35 additions, 19 deletions
tsk/hashdb/hdb_index.cpp
tsk/hashdb/sqlite_index.cpp
+1
-1
1 addition, 1 deletion
tsk/hashdb/sqlite_index.cpp
with
36 additions
and
20 deletions
tsk/hashdb/hdb_index.cpp
+
35
−
19
View file @
a8cd0103
...
...
@@ -81,6 +81,30 @@ tsk_idx_close_file(FILE * idx)
}
}
/**
* Update the hash type. New indices can handle multiple hash types, so hash
* type is now dependent on what the client is doing (e.g. lookup md5).
* @return 1 on error, 0 on success
*/
static
int
hdb_update_htype
(
TSK_HDB_INFO
*
hdb_info
,
uint8_t
htype
)
{
/* Get hash type specific information */
switch
(
htype
)
{
case
TSK_HDB_HTYPE_MD5_ID
:
hdb_info
->
hash_type
=
static_cast
<
TSK_HDB_HTYPE_ENUM
>
(
htype
);
hdb_info
->
hash_len
=
TSK_HDB_HTYPE_MD5_LEN
;
break
;
case
TSK_HDB_HTYPE_SHA1_ID
:
hdb_info
->
hash_type
=
static_cast
<
TSK_HDB_HTYPE_ENUM
>
(
htype
);
hdb_info
->
hash_len
=
TSK_HDB_HTYPE_SHA1_LEN
;
break
;
default:
return
1
;
}
return
0
;
}
/**
* Open an index for the given hash db
* We only create kdb (SQLite) files, but can open old indexes.
...
...
@@ -117,27 +141,16 @@ tsk_idx_open(TSK_HDB_INFO * hdb_info, uint8_t htype, uint8_t create)
return
NULL
;
}
/* Get hash type specific information */
switch
(
htype
)
{
case
TSK_HDB_HTYPE_MD5_ID
:
hdb_info
->
hash_type
=
static_cast
<
TSK_HDB_HTYPE_ENUM
>
(
htype
);
hdb_info
->
hash_len
=
TSK_HDB_HTYPE_MD5_LEN
;
break
;
case
TSK_HDB_HTYPE_SHA1_ID
:
hdb_info
->
hash_type
=
static_cast
<
TSK_HDB_HTYPE_ENUM
>
(
htype
);
hdb_info
->
hash_len
=
TSK_HDB_HTYPE_SHA1_LEN
;
break
;
default:
free
(
idx_info
);
tsk_error_reset
();
tsk_error_set_errno
(
TSK_ERR_HDB_MISSING
);
tsk_error_set_errstr
(
"tsk_idx_open: Unknown hash type: %d
\n
"
,
(
int
)
htype
);
return
NULL
;
if
(
hdb_update_htype
(
hdb_info
,
htype
)
==
1
)
{
free
(
idx_info
);
tsk_error_reset
();
tsk_error_set_errno
(
TSK_ERR_HDB_MISSING
);
tsk_error_set_errstr
(
"tsk_idx_open: Unknown hash type: %d
\n
"
,
(
int
)
htype
);
return
NULL
;
}
// Verify the new SQLite index exists, get its size, and open it for header reading
// Set SQLite index filename
...
...
@@ -308,6 +321,9 @@ hdb_setupindex(TSK_HDB_INFO * hdb_info, uint8_t htype, uint8_t create)
// already opened
if
(
hdb_info
->
idx_info
!=
NULL
)
{
// update htype
hdb_update_htype
(
hdb_info
,
htype
);
tsk_release_lock
(
&
hdb_info
->
lock
);
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
tsk/hashdb/sqlite_index.cpp
+
1
−
1
View file @
a8cd0103
...
...
@@ -506,7 +506,7 @@ sqlite_v1_lookup_raw(TSK_HDB_INFO * hdb_info, uint8_t * hvalue, uint8_t len,
tsk_error_reset
();
tsk_error_set_errno
(
TSK_ERR_HDB_ARG
);
tsk_error_set_errstr
(
"hdb_lookup: Hash passed is different size than expected: %d vs %d"
,
hdb_info
->
hash_len
,
len
);
hdb_info
->
hash_len
,
(
len
*
2
)
);
ret
=
-
1
;
}
else
{
...
...
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