From 3946aa12ed1d4cc138288a966354d41c0154e082 Mon Sep 17 00:00:00 2001 From: "Samuel H. Kenyon" <skenyon@basistech.com> Date: Wed, 13 Nov 2013 15:28:46 -0500 Subject: [PATCH] In hashDbIndexPathNat(), setup the index temporarily if it's not already in order to generate a legacy index path. --- bindings/java/jni/dataModel_SleuthkitJNI.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index 48a0ea0e1..ccbc5c4d7 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -478,7 +478,23 @@ JNIEXPORT jstring JNICALL return env->NewStringUTF(none); } else { TSK_HDB_INFO * db = m_hashDbs.at(dbHandle-1); - if((db != NULL) && (db->idx_info != NULL)) { + if (db == NULL) { + setThrowTskCoreError(env, "Invalid database"); + return env->NewStringUTF(none); + } + + ///@todo there isn't a db type for this (would be needed to get legacy index filename) + /*if(db->db_type == TSK_HDB_DBTYPE_NSRL_SHA1_ID) { + db->hash_type = TSK_HDB_HTYPE_SHA1_ID; + }*/ + //else { + db->hash_type = TSK_HDB_HTYPE_MD5_ID; + //} + + // Call setup to populate the idx_info struct so we can get the filename + tsk_hdb_idxsetup(db, db->hash_type); + + if(db->idx_info != NULL) { snprintf(cpath, 1024, "%" PRIttocTSK, db->idx_info->idx_fname); jstring jname = env->NewStringUTF(cpath); return jname; -- GitLab