diff --git a/bindings/java/jni/auto_db_java.cpp b/bindings/java/jni/auto_db_java.cpp index 09bc0400a6ef6ac2f6c0a687745f9c213daff2d8..56b2d758106400ae7f574ef3ad438078a9db2e86 100644 --- a/bindings/java/jni/auto_db_java.cpp +++ b/bindings/java/jni/auto_db_java.cpp @@ -597,7 +597,9 @@ TskAutoDbJava::addFile(TSK_FS_FILE* fs_file, // Add the attribute name if (attr_nlen > 0) { strncat(name, ":", nlen - strlen(name)); - strncat(name, fs_attr->name, nlen - strlen(name)); + if (fs_attr != NULL) { + strncat(name, fs_attr->name, nlen - strlen(name)); + } } // clean up path @@ -1945,7 +1947,6 @@ TSK_RETVAL_ENUM TskAutoDbJava::addUnallocFsSpaceToDb(size_t & numFs) { //TODO set parent_path for newly created virt dir/file hierarchy for consistency return allFsProcessRet; - return TSK_OK; } /** diff --git a/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java b/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java index 9efb3f0589c6ce37f326ed9f21ebe9357624eb01..2e9bc72106ebea19430ba617dee1f9a232a306f3 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java +++ b/bindings/java/src/org/sleuthkit/datamodel/JniDbHelper.java @@ -312,7 +312,7 @@ long addLayoutFile(long parentObjId, fsObjIdForDb = null; } - long objId = caseDb.addFileJNI(parentObjId, + return caseDb.addFileJNI(parentObjId, fsObjIdForDb, dataSourceObjId, fileType, null, null, name, @@ -327,7 +327,6 @@ long addLayoutFile(long parentObjId, null, TskData.FileKnown.UNKNOWN, null, null, true, trans); - return objId; } catch (TskCoreException ex) { logger.log(Level.SEVERE, "Error adding layout file to the database - parent object ID: " + parentObjId + ", file system object ID: " + fsObjId + ", name: " + name, ex); diff --git a/tsk/fs/fs_name.c b/tsk/fs/fs_name.c index 532f8d8f5473986ee2b9a4361a1307ced04440e7..a687fcf8bb62fcd65777ecc83424cfdecf1f6edc 100755 --- a/tsk/fs/fs_name.c +++ b/tsk/fs/fs_name.c @@ -297,13 +297,13 @@ tsk_fs_meta_make_ls(const TSK_FS_META * a_fs_meta, char *a_buf, char * tsk_fs_time_to_str(time_t time, char buf[128]) { + struct tm *tmTime; + buf[0] = '\0'; - if (time <= 0) { + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { strncpy(buf, "0000-00-00 00:00:00 (UTC)", 128); } else { - struct tm *tmTime = localtime(&time); - snprintf(buf, 128, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, @@ -326,13 +326,13 @@ char * tsk_fs_time_to_str_subsecs(time_t time, unsigned int subsecs, char buf[128]) { + struct tm *tmTime; + buf[0] = '\0'; - if (time <= 0) { + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { strncpy(buf, "0000-00-00 00:00:00 (UTC)", 32); } else { - struct tm *tmTime = localtime(&time); - snprintf(buf, 64, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d.%.9d (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, @@ -368,12 +368,12 @@ tsk_fs_print_time(FILE * hFile, time_t time) static void tsk_fs_print_day(FILE * hFile, time_t time) { - if (time <= 0) { + struct tm *tmTime; + + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { tsk_fprintf(hFile, "0000-00-00 00:00:00 (UTC)"); } else { - struct tm *tmTime = localtime(&time); - tsk_fprintf(hFile, "%.4d-%.2d-%.2d 00:00:00 (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday,