diff --git a/tsk/auto/db_postgresql.cpp b/tsk/auto/db_postgresql.cpp index a04518ae3e1830b5757abd59a0f0ab85904ed4dd..fe9570c575d5f393bcad28bc34aaf260e49d88d5 100755 --- a/tsk/auto/db_postgresql.cpp +++ b/tsk/auto/db_postgresql.cpp @@ -1057,13 +1057,21 @@ int TskDbPostgreSQL::addFile(TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr, return 1; } + //if dir, update parent id cache (do this before objId may be changed creating the slack file) + if (meta_type == TSK_FS_META_TYPE_DIR) { + std::string fullPath = std::string(path) + fs_file->name->name; + storeObjId(fsObjId, fs_file, fullPath.c_str(), objId); + } + // Add entry for the slack space. // Current conditions for creating a slack file: + // - File name is not empty, "." or ".." // - Data is non-resident // - The allocated size is greater than the initialized file size // See github issue #756 on why initsize and not size. // - The data is not compressed if((fs_attr != NULL) + && ((strlen(name) > 0) && (!TSK_FS_ISDOT(name))) && (! (fs_file->meta->flags & TSK_FS_META_FLAG_COMP)) && (fs_attr->flags & TSK_FS_ATTR_NONRES) && (fs_attr->nrd.allocsize > fs_attr->nrd.initsize)){ @@ -1094,7 +1102,7 @@ int TskDbPostgreSQL::addFile(TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr, TSK_DB_FILES_TYPE_SLACK, type, idx, name_sql, fs_file->name->meta_addr, fs_file->name->meta_seq, - fs_file->name->type, meta_type, fs_file->name->flags, meta_flags, + TSK_FS_NAME_TYPE_REG, TSK_FS_META_TYPE_REG, fs_file->name->flags, meta_flags, slackSize, (unsigned long long)crtime, (unsigned long long)ctime,(unsigned long long) atime,(unsigned long long) mtime, meta_mode, gid, uid, NULL, known, @@ -1110,12 +1118,6 @@ int TskDbPostgreSQL::addFile(TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr, } - //if dir, update parent id cache - if (meta_type == TSK_FS_META_TYPE_DIR) { - std::string fullPath = std::string(path) + fs_file->name->name; - storeObjId(fsObjId, fs_file, fullPath.c_str(), objId); - } - // cleanup free(name); free(escaped_path); diff --git a/tsk/auto/db_sqlite.cpp b/tsk/auto/db_sqlite.cpp index e135843fb33bbb5ac2549289c7e74238844feb5c..31afff5e0edbffc524722ca462ca6e54ff09a579 100755 --- a/tsk/auto/db_sqlite.cpp +++ b/tsk/auto/db_sqlite.cpp @@ -990,13 +990,21 @@ int return 1; } + //if dir, update parent id cache (do this before objId may be changed creating the slack file) + if (meta_type == TSK_FS_META_TYPE_DIR) { + std::string fullPath = std::string(path) + fs_file->name->name; + storeObjId(fsObjId, fs_file, fullPath.c_str(), objId); + } + // Add entry for the slack space. // Current conditions for creating a slack file: + // - File name is not empty, "." or ".." // - Data is non-resident // - The allocated size is greater than the initialized file size // See github issue #756 on why initsize and not size. // - The data is not compressed if((fs_attr != NULL) + && ((strlen(name) > 0 ) && (! TSK_FS_ISDOT(name))) && (!(fs_file->meta->flags & TSK_FS_META_FLAG_COMP)) && (fs_attr->flags & TSK_FS_ATTR_NONRES) && (fs_attr->nrd.allocsize > fs_attr->nrd.initsize)){ @@ -1028,7 +1036,7 @@ int TSK_DB_FILES_TYPE_SLACK, type, idx, name, fs_file->name->meta_addr, fs_file->name->meta_seq, - fs_file->name->type, meta_type, fs_file->name->flags, meta_flags, + TSK_FS_NAME_TYPE_REG, TSK_FS_META_TYPE_REG, fs_file->name->flags, meta_flags, slackSize, (unsigned long long)crtime, (unsigned long long)ctime,(unsigned long long) atime,(unsigned long long) mtime, meta_mode, gid, uid, md5TextPtr, known, @@ -1044,12 +1052,6 @@ int sqlite3_free(zSQL); - //if dir, update parent id cache - if (meta_type == TSK_FS_META_TYPE_DIR) { - std::string fullPath = std::string(path) + fs_file->name->name; - storeObjId(fsObjId, fs_file, fullPath.c_str(), objId); - } - free(name); free(escaped_path);