diff --git a/bindings/java/jni/Makefile.am b/bindings/java/jni/Makefile.am index 175b5c3acf7da750cf3209ea8dd7bf68d32d4147..b85e68a191a1a657a69ebb63b14dc2184e1c2ecb 100644 --- a/bindings/java/jni/Makefile.am +++ b/bindings/java/jni/Makefile.am @@ -1,4 +1,5 @@ -AM_CPPFLAGS = -I../../.. -I$(srcdir)/../../.. $(JNI_CPPFLAGS) +AM_CPPFLAGS = -I../../.. -I$(srcdir)/../../.. $(JNI_CPPFLAGS) +AM_CXXFLAGS += -Wno-unused-command-line-argument -Wno-overloaded-virtual EXTRA_DIST = .indent.pro lib_LTLIBRARIES = libtsk_jni.la diff --git a/configure.ac b/configure.ac index 1a5c6dd6b9eb54ad282d2ed9ae8d012ad511e10e..d05fdf2cdbe8a841ef696e1ac90cc30573b6db23 100644 --- a/configure.ac +++ b/configure.ac @@ -386,9 +386,7 @@ AC_CHECK_FUNCS([getline]) AC_SEARCH_LIBS(regexec, [regex], , AC_MSG_ERROR([missing regex])) dnl Enable compliation warnings -dnl TODO: Maybe turn on -Wpedantic after fixing all the other warnings? -dnl WARNINGS='-Wall -Wextra -Wpedantic' -WARNINGS='-Wall -Wextra -Wpedantic' +WARNINGS='-Wall -Wextra -Wno-unused-parameter' AC_SUBST(AM_CFLAGS, $WARNINGS) AC_SUBST(AM_CXXFLAGS, $WARNINGS) diff --git a/samples/Makefile.am b/samples/Makefile.am index 9d534772a078c495aee585964b9f5bc9f4d1b66f..7fc68a25afc458a9841b8e8c4376fff5dcfb0b72 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I.. -I$(srcdir)/.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../tsk/libtsk.la AM_LDFLAGS = -static EXTRA_DIST = .indent.pro diff --git a/tests/Makefile.am b/tests/Makefile.am index 59b508e0dbc490214f7244a49aa7fd22d9206aef..4f522cd821e7cd04ebfc42a70e2da1f3838040d4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I.. -I$(srcdir)/.. AM_CFLAGS += $(PTHREAD_CFLAGS) -AM_CXXFLAGS += $(PTHREAD_CFLAGS) +AM_CXXFLAGS += -Wno-unused-command-line-argument $(PTHREAD_CFLAGS) LDADD = ../tsk/libtsk.la LDFLAGS += -static $(PTHREAD_LIBS) EXTRA_DIST = .indent.pro runtests.sh diff --git a/tools/autotools/Makefile.am b/tools/autotools/Makefile.am index 0c387d6fc6297fceac540345a74d045d9f8ff3ec..8058968f8be96ddcd593b01bb6dfea43b11840b6 100644 --- a/tools/autotools/Makefile.am +++ b/tools/autotools/Makefile.am @@ -1,4 +1,5 @@ -AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-overloaded-virtual -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la LDFLAGS += -static EXTRA_DIST = .indent.pro diff --git a/tools/autotools/tsk_comparedir.cpp b/tools/autotools/tsk_comparedir.cpp index 6af829a83efae6861d5e47b786bd7902e6b41624..918840f507c6993f7c3307960e2196acb7250a2b 100644 --- a/tools/autotools/tsk_comparedir.cpp +++ b/tools/autotools/tsk_comparedir.cpp @@ -293,7 +293,7 @@ uint8_t else { std::set < char *, ltstr >::iterator it; for (it = m_filesInImg.begin(); it != m_filesInImg.end(); ++it) - printf("file: %s not found in directory\n", + printf("file: %" PRIttocTSK " not found in directory\n", (TSK_TCHAR *) * it); } diff --git a/tools/autotools/tsk_recover.cpp b/tools/autotools/tsk_recover.cpp index 6950952538d46f2ad7e1194f3ee21dc5c8152762..1db62221483767beb0fb890664203adc515e5246 100644 --- a/tools/autotools/tsk_recover.cpp +++ b/tools/autotools/tsk_recover.cpp @@ -89,14 +89,14 @@ uint8_t TskRecover::handleError() * Callback used to walk file content and write the results to the recovery file. */ static TSK_WALK_RET_ENUM -file_walk_cb(TSK_FS_FILE * /*a_fs_file*/, TSK_OFF_T /*a_off*/, - TSK_DADDR_T /*a_addr*/, char *a_buf, size_t a_len, - TSK_FS_BLOCK_FLAG_ENUM /*a_flags*/, void *a_ptr) +file_walk_cb(TSK_FS_FILE * a_fs_file, TSK_OFF_T a_off, + TSK_DADDR_T a_addr, char *a_buf, size_t a_len, + TSK_FS_BLOCK_FLAG_ENUM a_flags, void *a_ptr) { //write to the file #ifdef TSK_WIN32 DWORD written = 0; - if (!WriteFile((HANDLE) a_ptr, a_buf, a_len, &written, NULL)) { + if (!WriteFile((HANDLE) a_ptr, a_buf, (DWORD)a_len, &written, NULL)) { fprintf(stderr, "Error writing file content\n"); return TSK_WALK_ERROR; } diff --git a/tools/fiwalk/plugins/Makefile.am b/tools/fiwalk/plugins/Makefile.am index 54b3460a83cd684c3ebb234e9df00a6e53b4a3af..64513bcebcba06662937bd9422370da94c6bd4af 100644 --- a/tools/fiwalk/plugins/Makefile.am +++ b/tools/fiwalk/plugins/Makefile.am @@ -1,3 +1,4 @@ +AM_CXXFLAGS += -Wno-unused-command-line-argument bin_PROGRAMS = jpeg_extract jpeg_extract_SOURCES = jpeg_extract.cpp diff --git a/tools/fiwalk/src/Makefile.am b/tools/fiwalk/src/Makefile.am index cf6af570b97047a25d4229b200a78d84a4a29e1a..dc92ebfc35862dbc8f860dbb5c803ebc93a38788 100644 --- a/tools/fiwalk/src/Makefile.am +++ b/tools/fiwalk/src/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS = fiwalk - AM_CPPFLAGS = -I../../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../../tsk/libtsk.la EXTRA_DIST = README_PLUGINS.txt ficonfig.txt \ diff --git a/tools/fstools/Makefile.am b/tools/fstools/Makefile.am index e2ecdbd98e738c97df6c9f83a17e526969dbe656..cb9a138cac6264969203dd8e0ad542c76cf6314a 100644 --- a/tools/fstools/Makefile.am +++ b/tools/fstools/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la LDFLAGS += -static EXTRA_DIST = .indent.pro fscheck.cpp diff --git a/tools/hashtools/Makefile.am b/tools/hashtools/Makefile.am index 36aa48e6dcf8c3d160f3008252e5454b5ced129e..4241b2aabb2efa74315957f180c2e0e643187005 100644 --- a/tools/hashtools/Makefile.am +++ b/tools/hashtools/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la LDFLAGS += -static EXTRA_DIST = .indent.pro md5.c sha1.c diff --git a/tools/imgtools/Makefile.am b/tools/imgtools/Makefile.am index aebc96688dffdfa7f36fa2e042e533d0aa1daad3..30d3a25d3f46690f1b2fa7ee01e3a91a28b34925 100644 --- a/tools/imgtools/Makefile.am +++ b/tools/imgtools/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la LDFLAGS += -static EXTRA_DIST = .indent.pro diff --git a/tools/srchtools/Makefile.am b/tools/srchtools/Makefile.am index 665a6d2b8f8b84cbb920112c5ac693653aca1126..70a9af2bddf41c8d89cd3d584d3ac23b04804b7a 100644 --- a/tools/srchtools/Makefile.am +++ b/tools/srchtools/Makefile.am @@ -1,6 +1,8 @@ bin_PROGRAMS = srch_strings sigfind EXTRA_DIST = .indent.pro AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument +AM_CFLAGS += -Wno-unused-command-line-argument srch_strings_SOURCES = srch_strings.c diff --git a/tools/vstools/Makefile.am b/tools/vstools/Makefile.am index 13c1d35646f04b292f96befae13138b186a81f31..38475365d8ab97434f15cc226eb7214ed7b79684 100644 --- a/tools/vstools/Makefile.am +++ b/tools/vstools/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la LDFLAGS += -static EXTRA_DIST = .indent.pro diff --git a/travis_build.sh b/travis_build.sh index 1ec7fb70e7c124b019a6a8eb97f69a8fe722159c..a767b8534fdea8a82a14a00c8419bc48f12c23f0 100755 --- a/travis_build.sh +++ b/travis_build.sh @@ -6,5 +6,5 @@ if test ${TRAVIS_OS_NAME} = "linux"; then elif test ${TRAVIS_OS_NAME} = "osx"; then brew install ant fi -./bootstrap && ./configure --prefix=/usr && make +./bootstrap && ./configure --prefix=/usr && make > /dev/null cd bindings/java/ && ant dist-PostgreSQL diff --git a/tsk/auto/Makefile.am b/tsk/auto/Makefile.am index e9171b6f92f097ac97a72819c5dede9115ad1eb1..963dd9829de707cf85cc230cbefadb0dae0f97b4 100755 --- a/tsk/auto/Makefile.am +++ b/tsk/auto/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. -AM_CFLAGS += -Wmultichar -Wstrict-null-sentinel -Woverloaded-virtual -Wsign-promo -AM_CXXFLAGS += -Wmultichar -Wstrict-null-sentinel -Woverloaded-virtual -Wsign-promo +AM_CFLAGS += -Wmultichar -Wsign-promo -Wno-overloaded-virtual +AM_CXXFLAGS += -Wmultichar -Wsign-promo -Wno-overloaded-virtual EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskauto.la diff --git a/tsk/auto/auto_db.cpp b/tsk/auto/auto_db.cpp index 4b28f8e54bc67b7e16688a9e63d138414fd01e01..db5b2edc7596e6a979d8c971a072a9210097903c 100644 --- a/tsk/auto/auto_db.cpp +++ b/tsk/auto/auto_db.cpp @@ -40,7 +40,7 @@ TskAutoDb::TskAutoDb(TskDb * a_db, TSK_HDB_INFO * a_NSRLDb, TSK_HDB_INFO * a_kno m_curFsId = 0; m_curFileId = 0; m_curUnallocDirId = 0; - m_curDirId = 0; + m_curDirAddr = 0; m_curDirPath = ""; m_blkMapFlag = false; m_vsFound = false; @@ -729,13 +729,13 @@ TskAutoDb::processFile(TSK_FS_FILE * fs_file, const char *path) * is to grab the parent folder from files once we return back * into a folder when we are doing our depth-first recursion. */ if (isDir(fs_file)) { - m_curDirId = fs_file->name->meta_addr; + m_curDirAddr = fs_file->name->meta_addr; tsk_take_lock(&m_curDirPathLock); m_curDirPath = string(path) + fs_file->name->name; tsk_release_lock(&m_curDirPathLock); } - else if (m_curDirId != fs_file->name->par_addr) { - m_curDirId = fs_file->name->par_addr; + else if (m_curDirAddr != fs_file->name->par_addr) { + m_curDirAddr = fs_file->name->par_addr; tsk_take_lock(&m_curDirPathLock); m_curDirPath = path; tsk_release_lock(&m_curDirPathLock); diff --git a/tsk/auto/db_postgresql.cpp b/tsk/auto/db_postgresql.cpp index 62ca165df95cca57805ab4b4653a6e6784c2ef2e..9b0835d93af8c210c559f5802e931f607afc1949 100755 --- a/tsk/auto/db_postgresql.cpp +++ b/tsk/auto/db_postgresql.cpp @@ -73,28 +73,28 @@ TSK_RETVAL_ENUM TskDbPostgreSQL::verifyConnectionInfoStringLengths(size_t userNa if (userNameStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: User name is too long. Length = %d, Max length = %d", userNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: User name is too long. Length = %zd, Max length = %d", userNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); return TSK_ERR; } if (pwdStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Password is too long. Length = %d, Max length = %d", pwdStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Password is too long. Length = %zd, Max length = %d", pwdStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); return TSK_ERR; } if (hostNameStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host name is too long. Length = %d, Max length = %d", hostNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host name is too long. Length = %zd, Max length = %d", hostNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); return TSK_ERR; } if (portStrLen > MAX_CONN_PORT_FIELD_LENGTH) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host port string is too long. Length = %d, Max length = %d", portStrLen, MAX_CONN_PORT_FIELD_LENGTH); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host port string is too long. Length = %zd, Max length = %d", portStrLen, MAX_CONN_PORT_FIELD_LENGTH); return TSK_ERR; } @@ -712,7 +712,7 @@ int TskDbPostgreSQL::addVsInfo(const TSK_VS_INFO * vs_info, int64_t parObjId, in if (addObject(TSK_DB_OBJECT_TYPE_VS, parObjId, objId)) return 1; - snprintf(stmt, 1024, "INSERT INTO tsk_vs_info (obj_id, vs_type, img_offset, block_size) VALUES (%lld, %d,%" + snprintf(stmt, 1024, "INSERT INTO tsk_vs_info (obj_id, vs_type, img_offset, block_size) VALUES (%" PRId64 ", %d, %" PRIuOFF ",%u)", objId, vs_info->vstype, vs_info->offset, vs_info->block_size); return attempt_exec(stmt, "Error adding data to tsk_vs_info table: %s\n"); @@ -802,7 +802,7 @@ int TskDbPostgreSQL::addImageInfo(int type, TSK_OFF_T ssize, int64_t & objId, co PQfreemem(md5_sql); return 1; } - snprintf(stmt, 2048, "INSERT INTO tsk_image_info (obj_id, type, ssize, tzone, size, md5) VALUES (%lld, %d, %lld, %s, %" PRIuOFF ", %s);", + snprintf(stmt, 2048, "INSERT INTO tsk_image_info (obj_id, type, ssize, tzone, size, md5) VALUES (%" PRId64 ", %d, %" PRIuOFF ", %s, %" PRIuOFF ", %s);", objId, type, ssize, timezone_sql, size, md5_sql); int ret = attempt_exec(stmt, "Error adding data to tsk_image_info table: %s\n"); PQfreemem(timezone_sql); @@ -837,7 +837,7 @@ int TskDbPostgreSQL::addImageInfo(int type, TSK_OFF_T ssize, int64_t & objId, co PQfreemem(timeZone_sql); return 1; } - snprintf(stmt, 2048, "INSERT INTO data_source_info (obj_id, device_id, time_zone) VALUES (%lld, %s, %s);", + snprintf(stmt, 2048, "INSERT INTO data_source_info (obj_id, device_id, time_zone) VALUES (%" PRId64 ", %s, %s);", objId, deviceId_sql, timeZone_sql); ret = attempt_exec(stmt, "Error adding device id to data_source_info table: %s\n"); PQfreemem(deviceId_sql); @@ -862,7 +862,7 @@ int TskDbPostgreSQL::addImageName(int64_t objId, char const *imgName, int sequen return 1; } - snprintf(stmt, 2048, "INSERT INTO tsk_image_names (obj_id, name, sequence) VALUES (%lld, %s, %d)", objId, imgName_sql, sequence); + snprintf(stmt, 2048, "INSERT INTO tsk_image_names (obj_id, name, sequence) VALUES (%" PRId64 ", %s, %d)", objId, imgName_sql, sequence); int ret = attempt_exec(stmt, "Error adding data to tsk_image_names table: %s\n"); // cleanup @@ -886,7 +886,7 @@ int TskDbPostgreSQL::addFsInfo(const TSK_FS_INFO * fs_info, int64_t parObjId, in "INSERT INTO tsk_fs_info (obj_id, img_offset, fs_type, block_size, block_count, " "root_inum, first_inum, last_inum) " "VALUES (" - "%lld,%" PRIuOFF ",%d,%u,%" PRIuDADDR "," + "%" PRId64 ",%" PRIuOFF ",%d,%u,%" PRIuDADDR "," "%" PRIuINUM ",%" PRIuINUM ",%" PRIuINUM ")", objId, fs_info->offset, (int) fs_info->ftype, fs_info->block_size, fs_info->block_count, fs_info->root_inum, fs_info->first_inum, @@ -1539,8 +1539,8 @@ TSK_RETVAL_ENUM TskDbPostgreSQL::addVirtualDir(const int64_t fsObjId, const int6 "VALUES (" "NULL, NULL," "NULL," - "%lld," - "%lld," + "%" PRId64 "," + "%" PRId64 "," "%" PRId64 "," "%d," "%s," @@ -1781,7 +1781,7 @@ TSK_RETVAL_ENUM TskDbPostgreSQL::addLayoutFileInfo(const int64_t parObjId, const } snprintf(zSQL, 2048, "INSERT INTO tsk_files (has_layout, fs_obj_id, obj_id, data_source_obj_id, type, attr_type, attr_id, name, meta_addr, meta_seq, dir_type, meta_type, dir_flags, meta_flags, size, crtime, ctime, atime, mtime, mode, gid, uid) " "VALUES (" - "1, %s, %lld," + "1, %s, %" PRId64 "," "%" PRId64 "," "%d," "NULL,NULL,%s," @@ -1831,7 +1831,7 @@ int TskDbPostgreSQL::addVolumeInfo(const TSK_VS_PART_INFO * vs_part, } snprintf(zSQL, 1024, "INSERT INTO tsk_vs_parts (obj_id, addr, start, length, descr, flags)" - "VALUES (%lld, %" PRIuPNUM ",%" PRIuOFF ",%" PRIuOFF ",%s,%d)", + "VALUES (%" PRId64 ", %" PRIuPNUM ",%" PRIuOFF ",%" PRIuOFF ",%s,%d)", objId, (int) vs_part->addr, vs_part->start, vs_part->len, descr_sql, vs_part->flags); @@ -1855,7 +1855,7 @@ int TskDbPostgreSQL::addFileLayoutRange(int64_t a_fileObjId, uint64_t a_byteStar { char foo[1024]; - snprintf(foo, 1024, "INSERT INTO tsk_file_layout(obj_id, byte_start, byte_len, sequence) VALUES (%lld, %llu, %llu, %d)", + snprintf(foo, 1024, "INSERT INTO tsk_file_layout(obj_id, byte_start, byte_len, sequence) VALUES (%" PRId64 ", %" PRIu64 ", %" PRIu64 ", %d)", a_fileObjId, a_byteStart, a_byteLen, a_sequence); return attempt_exec(foo, "Error adding data to tsk_file_layout table: %s\n"); diff --git a/tsk/auto/tsk_case_db.h b/tsk/auto/tsk_case_db.h index d3c1eec04249a578a8f6a6161795bdc1e138bd82..851c577ee3d918c34ee41ddd79c5628efe94c1f8 100644 --- a/tsk/auto/tsk_case_db.h +++ b/tsk/auto/tsk_case_db.h @@ -128,7 +128,7 @@ class TskAutoDb:public TskAuto { int64_t m_curVolId; ///< Object ID of volume currently being processed int64_t m_curFsId; ///< Object ID of file system currently being processed int64_t m_curFileId; ///< Object ID of file currently being processed - int64_t m_curDirId; ///< Object ID of the directory currently being processed + TSK_INUM_T m_curDirAddr; ///< Meta address the directory currently being processed int64_t m_curUnallocDirId; string m_curDirPath; //< Path of the current directory being processed tsk_lock_t m_curDirPathLock; //< protects concurrent access to m_curDirPath diff --git a/tsk/base/tsk_base.h b/tsk/base/tsk_base.h index 85c04f312ea3ca2f7844a410d4eccec0dec58099..cdd9bfffda2839c8405612fe254bfd48912d05c7 100644 --- a/tsk/base/tsk_base.h +++ b/tsk/base/tsk_base.h @@ -288,7 +288,7 @@ extern "C" { typedef enum { TSK_WALK_CONT = 0x0, ///< Walk function should continue to next object TSK_WALK_STOP = 0x1, ///< Walk function should stop processing units and return OK - TSK_WALK_ERROR = 0x2, ///< Walk function should stop processing units and return error + TSK_WALK_ERROR = 0x2 ///< Walk function should stop processing units and return error } TSK_WALK_RET_ENUM; diff --git a/tsk/fs/dcalc_lib.c b/tsk/fs/dcalc_lib.c index 04477c9c1bdd9ee3fb4f70a6a85f3637e1e9ccba..a962f258e26728a85b20ca95c19d0531625c42fe 100644 --- a/tsk/fs/dcalc_lib.c +++ b/tsk/fs/dcalc_lib.c @@ -105,28 +105,18 @@ count_slack_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, "count_slack_file_act: Remaining File: %" PRIuOFF " Buffer: %" PRIuSIZE "\n", data->flen, size); - /* This is not the last data unit */ - if (data->flen >= size) { + /* This is not the last data unit, or the file has no slack */ + if (data->flen >= (TSK_OFF_T)size) { data->flen -= size; } - /* We have passed the end of the allocated space */ - else if (data->flen == 0) { - if (data->count-- == 0) { - tsk_printf("%" PRIuDADDR "\n", addr); - data->found = 1; - return TSK_WALK_STOP; - - } - } - /* This is the last data unit and there is unused space */ - else if (data->flen < size) { + else { + /* We have passed the end of the allocated space */ if (data->count-- == 0) { tsk_printf("%" PRIuDADDR "\n", addr); data->found = 1; return TSK_WALK_STOP; - } - data->flen = 0; + data->flen = 0; // for scenarios where last buffer had some unalloc } return TSK_WALK_CONT; diff --git a/tsk/fs/dcat_lib.c b/tsk/fs/dcat_lib.c index 7034dbaaa12479bc3c4d6a870b802fe8210b6c91..e05e2cc2daafc3a8fa3daa5eec24638557833db7 100644 --- a/tsk/fs/dcat_lib.c +++ b/tsk/fs/dcat_lib.c @@ -58,7 +58,7 @@ tsk_fs_blkcat(TSK_FS_INFO * fs, TSK_FS_BLKCAT_FLAG_ENUM lclflags, TSK_DADDR_T addr, TSK_DADDR_T read_num_units) { char *buf; - int i; + TSK_DADDR_T i; if (lclflags & TSK_FS_BLKCAT_STAT) { stats(fs); diff --git a/tsk/fs/dls_lib.c b/tsk/fs/dls_lib.c index 910d9559f0345ee96de2b13c740b6c39d360f6bf..66421c8fa0ae003b8dbe733d7e716b71bf8e1bda 100644 --- a/tsk/fs/dls_lib.c +++ b/tsk/fs/dls_lib.c @@ -122,23 +122,17 @@ slack_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, size); /* This is not the last data unit */ - if (data->flen >= size) { + if (data->flen >= (TSK_OFF_T)size) { data->flen -= size; } /* We have passed the end of the allocated space */ - else if (data->flen == 0) { - if (fwrite(buf, size, 1, stdout) != 1) { - tsk_error_reset(); - tsk_error_set_errno(TSK_ERR_FS_WRITE); - tsk_error_set_errstr("blkls_lib: error writing to stdout: %s", - strerror(errno)); - return TSK_WALK_ERROR; + else { + /* This is the last data unit and there is unused space + * reset the used space */ + if (data->flen != 0) { + memset(buf, 0, (size_t) data->flen); + data->flen = 0; } - } - /* This is the last data unit and there is unused space */ - else if (data->flen < size) { - /* Clear the used space and print it */ - memset(buf, 0, (size_t) data->flen); if (fwrite(buf, size, 1, stdout) != 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_WRITE); @@ -146,7 +140,6 @@ slack_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, strerror(errno)); return TSK_WALK_ERROR; } - data->flen = 0; } return TSK_WALK_CONT; diff --git a/tsk/fs/ext2fs.c b/tsk/fs/ext2fs.c index 316158fc1e534c2dfb5a5cc387329d0eb7399606..019071b7ced73cb5d41f63cb57956aedb807e569 100644 --- a/tsk/fs/ext2fs.c +++ b/tsk/fs/ext2fs.c @@ -135,7 +135,7 @@ static uint8_t TSK_OFF_T offs; ssize_t cnt; - if (gd_size < sizeof(ext4fs_gd)) + if (gd_size < (int)sizeof(ext4fs_gd)) gd_size = sizeof(ext4fs_gd); if (ext2fs->ext4_grp_buf == NULL) { @@ -180,7 +180,7 @@ static uint8_t else { TSK_OFF_T offs; ssize_t cnt; - if (gd_size < sizeof(ext2fs_gd)) + if (gd_size < (int)sizeof(ext2fs_gd)) gd_size = sizeof(ext2fs_gd); if (ext2fs->grp_buf == NULL) { @@ -923,7 +923,7 @@ ext2fs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum_tmp; TSK_INUM_T ibase = 0; TSK_FS_FILE *fs_file; - int myflags; + unsigned int myflags; ext2fs_inode *dino_buf = NULL; unsigned int size = 0; diff --git a/tsk/fs/ext2fs_dent.c b/tsk/fs/ext2fs_dent.c index c752c17f70fce1539599e46c74594ffaa6112ac8..5f380ec1d75ef539ad76c42de1c20b6ac7c18ceb 100644 --- a/tsk/fs/ext2fs_dent.c +++ b/tsk/fs/ext2fs_dent.c @@ -324,9 +324,8 @@ ext2fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, int len = (a_fs->block_size < size) ? a_fs->block_size : (int) size; - int cnt = tsk_fs_file_read(fs_dir->fs_file, offset, dirbuf, len, (TSK_FS_FILE_READ_FLAG_ENUM)0); + ssize_t cnt = tsk_fs_file_read(fs_dir->fs_file, offset, dirbuf, len, (TSK_FS_FILE_READ_FLAG_ENUM)0); if (cnt != len) { - printf(" Failed - read 0x%x bytes\n", cnt); tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_FWALK); tsk_error_set_errstr diff --git a/tsk/fs/ext2fs_journal.c b/tsk/fs/ext2fs_journal.c index 73674c5281cbb23e3de193db39d110a8b6aa8c1c..61bdb35bb97f82bc2eeacaf1d2c565a29dd38d87 100644 --- a/tsk/fs/ext2fs_journal.c +++ b/tsk/fs/ext2fs_journal.c @@ -154,7 +154,7 @@ ext2fs_jentry_walk(TSK_FS_INFO * fs, int flags, return 1; } - if (jinfo->fs_file->meta->size != + if ((TSK_DADDR_T)jinfo->fs_file->meta->size != (jinfo->last_block + 1) * jinfo->bsize) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_ARG); @@ -519,7 +519,7 @@ ext2fs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, return 1; } - if (jinfo->fs_file->meta->size != + if ((TSK_DADDR_T)jinfo->fs_file->meta->size != (jinfo->last_block + 1) * jinfo->bsize) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_UNSUPFUNC); diff --git a/tsk/fs/fatfs.c b/tsk/fs/fatfs.c index d26f259cd3bf2f3e5a1c89f86feacce5c6456562..fe3ab172723ba9ae29f864afa873b6081b32b409 100644 --- a/tsk/fs/fatfs.c +++ b/tsk/fs/fatfs.c @@ -36,8 +36,6 @@ fatfs_open(TSK_IMG_INFO *a_img_info, TSK_OFF_T a_offset, TSK_FS_TYPE_ENUM a_ftyp FATFS_INFO *fatfs = NULL; TSK_FS_INFO *fs = NULL; int find_boot_sector_attempt = 0; - ssize_t bytes_read = 0; - FATFS_MASTER_BOOT_RECORD *bootSector; tsk_error_reset(); @@ -70,6 +68,8 @@ fatfs_open(TSK_IMG_INFO *a_img_info, TSK_OFF_T a_offset, TSK_FS_TYPE_ENUM a_ftyp // Look for a FAT boot sector. Try up to three times because FAT32 and exFAT file systems have backup boot sectors. for (find_boot_sector_attempt = 0; find_boot_sector_attempt < 3; ++find_boot_sector_attempt) { TSK_OFF_T boot_sector_offset; + FATFS_MASTER_BOOT_RECORD *bootSector; + ssize_t bytes_read = 0; switch (find_boot_sector_attempt) { case 0: @@ -238,7 +238,6 @@ fatfs_getFAT(FATFS_INFO * fatfs, TSK_DADDR_T clust, TSK_DADDR_T * value) uint16_t tmp16; TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; TSK_DADDR_T sect, offs; - ssize_t cnt; int cidx; /* Sanity Check */ @@ -293,6 +292,7 @@ fatfs_getFAT(FATFS_INFO * fatfs, TSK_DADDR_T clust, TSK_DADDR_T * value) * size must therefore be at least 2 sectors large */ if (offs == (FATFS_FAT_CACHE_B - 1)) { + ssize_t cnt; // read the data -- TTLs will already have been updated cnt = @@ -648,7 +648,7 @@ fatfs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, if ((a_flags & TSK_FS_BLOCK_WALK_FLAG_AONLY) == 0) { cnt = tsk_fs_read_block (fs, addr, data_buf, fs->block_size * read_size); - if (cnt != fs->block_size * read_size) { + if (cnt != (ssize_t)(fs->block_size * read_size)) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); diff --git a/tsk/fs/fatfs_meta.c b/tsk/fs/fatfs_meta.c index f2cd6c62c5c4e26f466a611a57e718299e63e5e7..b219779d8f6340bfdb3d847ac8e7893086f602f9 100755 --- a/tsk/fs/fatfs_meta.c +++ b/tsk/fs/fatfs_meta.c @@ -1373,7 +1373,7 @@ fatfs_inode_walk(TSK_FS_INFO *a_fs, TSK_INUM_T a_start_inum, /* Read in a cluster. */ cnt = tsk_fs_read_block (a_fs, sect, dino_buf, num_sectors_to_process << fatfs->ssize_sh); - if (cnt != (num_sectors_to_process << fatfs->ssize_sh)) { + if (cnt != (ssize_t)(num_sectors_to_process << fatfs->ssize_sh)) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); diff --git a/tsk/fs/ffs.c b/tsk/fs/ffs.c index 61c5e6572bd914419c9176a60f02d87842bf2489..10e69140f683367b70b47b7a116d4984ec0d0c18 100644 --- a/tsk/fs/ffs.c +++ b/tsk/fs/ffs.c @@ -85,8 +85,8 @@ ffs_group_load(FFS_INFO * ffs, FFS_GRPNUM_T grp_num) /* Perform a sanity check on the data to make sure offsets are in range */ cg = (ffs_cgd *) ffs->grp_buf; - if ((tsk_gets32(fs->endian, cg->cg_iusedoff) > ffs->ffsbsize_b) - || (tsk_gets32(fs->endian, cg->cg_freeoff) > ffs->ffsbsize_b)) { + if ((tsk_gets32(fs->endian, cg->cg_iusedoff) > (int)ffs->ffsbsize_b) + || (tsk_gets32(fs->endian, cg->cg_freeoff) > (int)ffs->ffsbsize_b)) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_CORRUPT); tsk_error_set_errstr2("ffs_group_load: Group %" PRI_FFSGRP @@ -850,7 +850,7 @@ ffs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T inum; unsigned char *inosused = NULL; TSK_FS_FILE *fs_file; - int myflags; + unsigned int myflags; TSK_INUM_T ibase = 0; TSK_INUM_T end_inum_tmp; ffs_inode *dino_buf; diff --git a/tsk/fs/ffs_dent.c b/tsk/fs/ffs_dent.c index 4f3785871b9f2590ce6b1f426e665aad848331af..a9e9aec334c72fb7343acb4c2bd7d2f6c83cd984 100644 --- a/tsk/fs/ffs_dent.c +++ b/tsk/fs/ffs_dent.c @@ -303,9 +303,8 @@ ffs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, for (cidx = 0; cidx < nchnk && (int64_t) size > 0; cidx++) { int len = (FFS_DIRBLKSIZ < size) ? FFS_DIRBLKSIZ : (int) size; - int cnt = tsk_fs_file_read(fs_dir->fs_file, offset, dirbuf, len, (TSK_FS_FILE_READ_FLAG_ENUM)0); + ssize_t cnt = tsk_fs_file_read(fs_dir->fs_file, offset, dirbuf, len, (TSK_FS_FILE_READ_FLAG_ENUM)0); if (cnt != len) { - printf(" Failed - read 0x%x bytes\n", cnt); tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_FWALK); tsk_error_set_errstr diff --git a/tsk/fs/fs_attr.c b/tsk/fs/fs_attr.c index a7d80da646a268417448dc3ec882f54f22dc09dc..6b59f4f58d8b05733f579ef047a41aa48838c96b 100644 --- a/tsk/fs/fs_attr.c +++ b/tsk/fs/fs_attr.c @@ -797,7 +797,7 @@ tsk_fs_attr_walk_res(const TSK_FS_ATTR * fs_attr, retval = TSK_WALK_CONT; for (off = 0; off < fs_attr->size; off += read_len) { - if (fs_attr->size - off > buf_len) + if (fs_attr->size - off > (TSK_OFF_T)buf_len) read_len = buf_len; else read_len = (size_t) (fs_attr->size - off); @@ -1133,7 +1133,7 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, } len_toread = a_len; - if (a_offset + a_len > a_fs_attr->size) { + if (a_offset + (TSK_OFF_T)a_len > a_fs_attr->size) { len_toread = (size_t) (a_fs_attr->size - a_offset); memset(&a_buf[len_toread], 0, a_len - len_toread); } @@ -1148,7 +1148,7 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, TSK_FS_ATTR_RUN *data_run_cur; TSK_DADDR_T blkoffset_toread; // block offset of where we want to start reading from size_t byteoffset_toread; // byte offset in blkoffset_toread of where we want to start reading from - size_t len_remain; // length remaining to copy + ssize_t len_remain; // length remaining to copy size_t len_toread; // length total to copy if (((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) @@ -1167,12 +1167,12 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, // determine how many bytes we can copy len_toread = a_len; if (a_flags & TSK_FS_FILE_READ_FLAG_SLACK) { - if (a_offset + a_len > a_fs_attr->nrd.allocsize) + if (a_offset + (TSK_OFF_T)a_len > a_fs_attr->nrd.allocsize) len_toread = (size_t) (a_fs_attr->nrd.allocsize - a_offset); } else { - if (a_offset + a_len > a_fs_attr->size) + if (a_offset + (TSK_OFF_T)a_len > a_fs_attr->size) len_toread = (size_t) (a_fs_attr->size - a_offset); } // wipe the buffer we won't read into @@ -1205,7 +1205,7 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, // see if we need to read the rest of this run and into the next or if it is all here len_inrun = len_remain; if ((data_run_cur->len - blkoffset_inrun) * fs->block_size - - byteoffset_toread < len_remain) + byteoffset_toread < (size_t)len_remain) len_inrun = (size_t) ((data_run_cur->len - blkoffset_inrun) * fs->block_size - @@ -1259,7 +1259,7 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, cnt = tsk_fs_read(fs, fs_offset_b, &a_buf[len_toread - len_remain], len_inrun); - if (cnt != len_inrun) { + if (cnt != (ssize_t)len_inrun) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); diff --git a/tsk/fs/fs_block.c b/tsk/fs/fs_block.c index 47b27e1916056169537071902f56404d4f273bf8..61fccf98c87c66aed1c75551c014e5fcdca64596 100644 --- a/tsk/fs/fs_block.c +++ b/tsk/fs/fs_block.c @@ -83,7 +83,6 @@ tsk_fs_block_get_flag(TSK_FS_INFO * a_fs, TSK_FS_BLOCK * a_fs_block, TSK_DADDR_T a_addr, TSK_FS_BLOCK_FLAG_ENUM a_flags) { TSK_OFF_T offs; - ssize_t cnt; size_t len; if (a_fs == NULL) { @@ -126,10 +125,11 @@ tsk_fs_block_get_flag(TSK_FS_INFO * a_fs, TSK_FS_BLOCK * a_fs_block, offs = (TSK_OFF_T) a_addr *a_fs->block_size; if ((a_fs_block->flags & TSK_FS_BLOCK_FLAG_AONLY) == 0) { + ssize_t cnt; cnt = tsk_img_read(a_fs->img_info, a_fs->offset + offs, a_fs_block->buf, len); - if (cnt != len) { + if (cnt != (ssize_t)len) { return NULL; } } diff --git a/tsk/fs/fs_io.c b/tsk/fs/fs_io.c index 760cc8da63b9c065b62559dd75c4db20d805867e..c8f960c170c6e84d6ca142cde927c3801dd862a8 100644 --- a/tsk/fs/fs_io.c +++ b/tsk/fs/fs_io.c @@ -51,7 +51,7 @@ fs_prepost_read(TSK_FS_INFO * a_fs, TSK_OFF_T a_off, char *a_buf, TSK_DADDR_T blk = cur_off / a_fs->block_size; size_t read_len = a_fs->block_size - cur_off % a_fs->block_size; - if (read_len + cur_off > end_off) + if ((TSK_OFF_T)read_len + cur_off > end_off) read_len = (size_t) (end_off - cur_off); read_off = diff --git a/tsk/fs/fs_open.c b/tsk/fs/fs_open.c index 6f7404922cae9a6bff52e89016215c16a4a28115..602d3677dcec4c83856cfa4f259faf06ef8e333f 100644 --- a/tsk/fs/fs_open.c +++ b/tsk/fs/fs_open.c @@ -83,9 +83,7 @@ TSK_FS_INFO * tsk_fs_open_img(TSK_IMG_INFO * a_img_info, TSK_OFF_T a_offset, TSK_FS_TYPE_ENUM a_ftype) { - TSK_FS_INFO *fs_info, *fs_first = NULL; - const char *name_first; - int i; + TSK_FS_INFO *fs_info; const struct { char* name; @@ -115,6 +113,10 @@ tsk_fs_open_img(TSK_IMG_INFO * a_img_info, TSK_OFF_T a_offset, * We need to try all of them in case more than one matches */ if (a_ftype == TSK_FS_TYPE_DETECT) { + unsigned long i; + const char *name_first = ""; + TSK_FS_INFO *fs_first = NULL; + if (tsk_verbose) tsk_fprintf(stderr, "fsopen: Auto detection mode at offset %" PRIuOFF "\n", diff --git a/tsk/fs/fs_types.c b/tsk/fs/fs_types.c index 38db26a4fa00cf4f64b9ccbf2dbd9892186c1ccd..aea78769e9d4dbf3967a948324bc976b523feecb 100644 --- a/tsk/fs/fs_types.c +++ b/tsk/fs/fs_types.c @@ -56,7 +56,7 @@ static FS_TYPES fs_type_table[] = { {"ufs1", TSK_FS_TYPE_FFS1, "UFS1"}, {"ufs2", TSK_FS_TYPE_FFS2, "UFS2"}, {"yaffs2", TSK_FS_TYPE_YAFFS2, "YAFFS2"}, - {0}, + {0,0,""} }; static FS_TYPES fs_legacy_type_table[] = { @@ -70,7 +70,7 @@ static FS_TYPES fs_legacy_type_table[] = { {"netbsd", TSK_FS_TYPE_FFS1, "NetBSD FFS"}, {"openbsd", TSK_FS_TYPE_FFS1, "OpenBSD FFS"}, {"solaris", TSK_FS_TYPE_FFS1B, "Solaris FFS"}, - {0}, + {0,0,""} }; diff --git a/tsk/fs/hfs.c b/tsk/fs/hfs.c index e1a8b4b16da405209fa987a6d4baa87ecc8dfb6d..3c58dd22d2a1a1a4bdce77a5f0481a8d510812d0 100644 --- a/tsk/fs/hfs.c +++ b/tsk/fs/hfs.c @@ -2631,7 +2631,7 @@ typedef struct { */ static int hfs_read_zlib_block_table(const TSK_FS_ATTR *rAttr, CMP_OFFSET_ENTRY** offsetTableOut, uint32_t* tableSizeOut, uint32_t* tableOffsetOut) { - int attrReadResult; + ssize_t attrReadResult; hfs_resource_fork_header rfHeader; uint32_t dataOffset; uint32_t offsetTableOffset; @@ -2730,7 +2730,7 @@ hfs_read_zlib_block_table(const TSK_FS_ATTR *rAttr, CMP_OFFSET_ENTRY** offsetTab */ static int hfs_read_lzvn_block_table(const TSK_FS_ATTR *rAttr, CMP_OFFSET_ENTRY** offsetTableOut, uint32_t* tableSizeOut, uint32_t* tableOffsetOut) { - int attrReadResult; + ssize_t attrReadResult; char fourBytes[4]; uint32_t tableDataSize; uint32_t tableSize; // Size of the offset table @@ -2932,7 +2932,7 @@ static ssize_t read_and_decompress_block( uint64_t* uncLen) ) { - int attrReadResult; + ssize_t attrReadResult; uint32_t offset = offsetTableOffset + offsetTable[indx].offset; uint32_t len = offsetTable[indx].length; uint64_t uncLen; @@ -3255,10 +3255,10 @@ hfs_file_read_compressed_rsrc(const TSK_FS_ATTR * a_fs_attr, uint32_t offsetTableOffset; uint32_t offsetTableSize; // Size of the offset table CMP_OFFSET_ENTRY *offsetTable = NULL; - size_t indx; // index for looping over the offset table - uint32_t startUnit = 0; + TSK_OFF_T indx; // index for looping over the offset table + TSK_OFF_T startUnit = 0; uint32_t startUnitOffset = 0; - uint32_t endUnit = 0; + TSK_OFF_T endUnit = 0; uint64_t bytesCopied; if (tsk_verbose) @@ -3346,8 +3346,8 @@ hfs_file_read_compressed_rsrc(const TSK_FS_ATTR * a_fs_attr, if (tsk_verbose) tsk_fprintf(stderr, - "%s: reading compression units: %" PRIu32 - " to %" PRIu32 "\n", __func__, startUnit, endUnit); + "%s: reading compression units: %" PRIuOFF + " to %" PRIuOFF "\n", __func__, startUnit, endUnit); bytesCopied = 0; // Allocate buffers for the raw and uncompressed data @@ -3376,7 +3376,7 @@ hfs_file_read_compressed_rsrc(const TSK_FS_ATTR * a_fs_attr, switch ((uncLen = read_and_decompress_block( rAttr, rawBuf, uncBuf, - offsetTable, offsetTableSize, offsetTableOffset, indx, + offsetTable, offsetTableSize, offsetTableOffset, (size_t)indx, decompress_block))) { case -1: @@ -3788,7 +3788,7 @@ static uint8_t open_attr_file(TSK_FS_INFO * fs, ATTR_FILE_T * attr_file) { - int cnt; // will hold bytes read + ssize_t cnt; // will hold bytes read hfs_btree_header_record *hrec; @@ -3835,7 +3835,7 @@ open_attr_file(TSK_FS_INFO * fs, ATTR_FILE_T * attr_file) 14, (char *) hrec, sizeof(hfs_btree_header_record), (TSK_FS_FILE_READ_FLAG_ENUM) 0); - if (cnt != sizeof(hfs_btree_header_record)) { + if (cnt != (ssize_t)sizeof(hfs_btree_header_record)) { tsk_error_set_errno(TSK_ERR_FS_READ); tsk_error_set_errstr ("open_attr_file: could not open the Attributes file"); @@ -3913,7 +3913,6 @@ hfs_load_extended_attrs(TSK_FS_FILE * fs_file, TSK_FS_INFO *fs = fs_file->fs_info; uint64_t fileID; ATTR_FILE_T attrFile; - int cnt; // count of chars read from file. uint8_t *nodeData; TSK_ENDIAN_ENUM endian; hfs_btree_node *nodeDescriptor; // The node descriptor @@ -3924,6 +3923,7 @@ hfs_load_extended_attrs(TSK_FS_FILE * fs_file, HFS_INFO *hfs; char *buffer = NULL; // buffer to hold the attribute TSK_LIST *nodeIDs_processed = NULL; // Keep track of node IDs to prevent an infinite loop + ssize_t cnt; // count of chars read from file. tsk_error_reset(); @@ -4009,7 +4009,7 @@ hfs_load_extended_attrs(TSK_FS_FILE * fs_file, (TSK_OFF_T)nodeID * attrFile.nodeSize, (char *) nodeData, attrFile.nodeSize, (TSK_FS_FILE_READ_FLAG_ENUM) 0); - if (cnt != attrFile.nodeSize) { + if (cnt != (ssize_t)attrFile.nodeSize) { error_returned ("hfs_load_extended_attrs: Could not read in a node from the Attributes File"); goto on_error; @@ -4272,14 +4272,14 @@ hfs_load_extended_attrs(TSK_FS_FILE * fs_file, // attr_name_len is in UTF_16 chars nameLength = tsk_getu16(endian, keyB->attr_name_len); - if (2*nameLength > HFS_MAX_ATTR_NAME_LEN_UTF16_B) { + if (2 * nameLength > HFS_MAX_ATTR_NAME_LEN_UTF16_B) { error_detected(TSK_ERR_FS_CORRUPT, "hfs_load_extended_attrs: Name length in bytes (%d) > max name length in bytes (%d).", 2*nameLength, HFS_MAX_ATTR_NAME_LEN_UTF16_B); goto on_error; } - if (2*nameLength > keyLength - 12) { + if (nameLength * (unsigned int)2 > keyLength - (unsigned int)12) { error_detected(TSK_ERR_FS_CORRUPT, "hfs_load_extended_attrs: Name length in bytes (%d) > remaining struct length (%d).", 2*nameLength, keyLength - 12); @@ -4444,7 +4444,7 @@ hfs_load_extended_attrs(TSK_FS_FILE * fs_file, nodeID * attrFile.nodeSize, (char *) nodeData, attrFile.nodeSize, (TSK_FS_FILE_READ_FLAG_ENUM) 0); - if (cnt != attrFile.nodeSize) { + if (cnt != (ssize_t)attrFile.nodeSize) { error_returned ("hfs_load_extended_attrs: Could not read in the next LEAF node from the Attributes File btree"); goto on_error; @@ -4529,9 +4529,9 @@ hfs_parse_resource_fork(TSK_FS_FILE * fs_file) uint32_t mapOffset; uint32_t mapLength; char *map; - int attrReadResult; - int attrReadResult1; - int attrReadResult2; + ssize_t attrReadResult; + ssize_t attrReadResult1; + ssize_t attrReadResult2; hfs_resource_fork_map_header *mapHdr; uint16_t typeListOffset; uint16_t nameListOffset; @@ -5171,7 +5171,7 @@ hfs_block_is_alloc(HFS_INFO * hfs, TSK_DADDR_T a_addr) if ((hfs->blockmap_cache_start == -1) || (hfs->blockmap_cache_start > b) || (hfs->blockmap_cache_start + hfs->blockmap_cache_len <= (size_t) b)) { - size_t cnt = tsk_fs_attr_read(hfs->blockmap_attr, b, + ssize_t cnt = tsk_fs_attr_read(hfs->blockmap_attr, b, hfs->blockmap_cache, sizeof(hfs->blockmap_cache), 0); if (cnt < 1) { @@ -6272,7 +6272,7 @@ hfs_istat(TSK_FS_INFO * fs, TSK_FS_ISTAT_FLAG_ENUM istat_flags, FILE * hFile, TS // IF this is a compressed file if (compressionAttr != NULL) { const TSK_FS_ATTR *fs_attr = compressionAttr; - int attrReadResult; + ssize_t attrReadResult; DECMPFS_DISK_HEADER *cmph; uint32_t cmpType; uint64_t uncSize; @@ -6896,12 +6896,12 @@ error_detected(uint32_t errnum, char *errstr, ...) else { //This should not happen! We don't want to wipe out the existing error //code, so we write the new code into the error string, in hex. - int sl = strlen(errstr); + size_t sl = strlen(errstr); snprintf(loc_errstr + sl, TSK_ERROR_STRING_MAX_LENGTH - sl, " Next errnum: 0x%x ", errnum); } if (errstr != NULL) { - int sl = strlen(loc_errstr); + size_t sl = strlen(loc_errstr); vsnprintf(loc_errstr + sl, TSK_ERROR_STRING_MAX_LENGTH - sl, errstr, args); } @@ -6933,7 +6933,7 @@ error_returned(char *errstr, ...) if (errInfo->t_errno == 0) errInfo->t_errno = TSK_ERR_AUX_GENERIC; if (errstr != NULL) { - int sl = strlen(loc_errstr2); + size_t sl = strlen(loc_errstr2); vsnprintf(loc_errstr2 + sl, TSK_ERROR_STRING_MAX_LENGTH - sl, errstr, args); } diff --git a/tsk/fs/hfs_dent.c b/tsk/fs/hfs_dent.c index 881a197b86ee01054363564d427a0786f7dcd8d6..c630054c92b3835f1478cdee4fde5c05c4ec3ebb 100644 --- a/tsk/fs/hfs_dent.c +++ b/tsk/fs/hfs_dent.c @@ -265,7 +265,7 @@ hfs_dir_open_meta_cb(HFS_INFO * hfs, int8_t level_type, // Make sure there is enough space in cur_key for the name // (name is unicode so each characters is two bytes; 6 bytes of non-name characters) - if ((uint32_t)(tsk_getu16(hfs->fs_info.endian, cur_key->name.length)) * 2 > tsk_getu16(hfs->fs_info.endian, cur_key->key_len) - 6) { + if ((uint32_t)(tsk_getu16(hfs->fs_info.endian, cur_key->name.length)) * (unsigned int)2 > tsk_getu16(hfs->fs_info.endian, cur_key->key_len) - (unsigned int)6) { error_returned ("hfs_dir_open_meta_cb: name length is too long"); return HFS_BTREE_CB_ERR; @@ -323,7 +323,7 @@ hfs_dir_open_meta_cb(HFS_INFO * hfs, int8_t level_type, // Make sure there is enough space in cur_key for the name // (name is unicode so each characters is two bytes; 6 bytes of non-name characters) - if ((uint32_t)(tsk_getu16(hfs->fs_info.endian, cur_key->name.length)) * 2 > tsk_getu16(hfs->fs_info.endian, cur_key->key_len) - 6) { + if ((uint32_t)(tsk_getu16(hfs->fs_info.endian, cur_key->name.length)) * (unsigned int)2 > tsk_getu16(hfs->fs_info.endian, cur_key->key_len) - (unsigned int)6) { error_returned ("hfs_dir_open_meta_cb: name length is too long"); return HFS_BTREE_CB_ERR; diff --git a/tsk/fs/iso9660.c b/tsk/fs/iso9660.c index f1d03473c134e9e508ae4f885399f172ce2019a1..8f50c95037804d00ebd00b5e78fc88d52f9049cb 100644 --- a/tsk/fs/iso9660.c +++ b/tsk/fs/iso9660.c @@ -1229,7 +1229,7 @@ iso9660_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start, TSK_INUM_T last, ISO_INFO *iso = (ISO_INFO *) fs; TSK_INUM_T inum, end_inum_tmp; TSK_FS_FILE *fs_file; - int myflags; + unsigned int myflags; iso9660_inode *dinode; // clean up any error messages that are lying around diff --git a/tsk/fs/iso9660_dent.c b/tsk/fs/iso9660_dent.c index dc8438da147581b3ee4ac66ea7dd94dfaa2a47a1..4dc4d61bf02e0db79436b374b190567eab480626 100644 --- a/tsk/fs/iso9660_dent.c +++ b/tsk/fs/iso9660_dent.c @@ -158,7 +158,7 @@ iso9660_proc_dir(TSK_FS_INFO * a_fs, TSK_FS_DIR * a_fs_dir, char *buf, * that had a file with 0 bytes with the same starting block as another * file. */ for (in = iso->in_list; in; in = in->next) { - if (in->dentry_offset == dir_offs + buf_idx) + if (in->dentry_offset == dir_offs + (TSK_OFF_T)buf_idx) break; } @@ -285,7 +285,7 @@ iso9660_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, return TSK_ERR; cnt = tsk_fs_file_read(fs_dir->fs_file, 0, buf, length, 0); - if (cnt != length) { + if (cnt != (ssize_t)length) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); diff --git a/tsk/fs/lzvn.c b/tsk/fs/lzvn.c index a923122ac1caeaf491715f6582a4562eed68c66c..f03afefa268346d4b02611191fe79a2d2d9d40c7 100644 --- a/tsk/fs/lzvn.c +++ b/tsk/fs/lzvn.c @@ -95,9 +95,11 @@ LZFSE_INLINE uint64_t load8(const void *ptr) { } /*! @abstract Store bytes to memory location DST. */ +/* LZFSE_INLINE void store2(void *ptr, uint16_t data) { memcpy(ptr, &data, sizeof data); } +*/ LZFSE_INLINE void store4(void *ptr, uint32_t data) { memcpy(ptr, &data, sizeof data); diff --git a/tsk/fs/ntfs.c b/tsk/fs/ntfs.c index f6ae77de478d60a618fcc94bb3b6108551af900d..4eb3c7fca92bdbdba6040a0a7fdb293ff41f542e 100755 --- a/tsk/fs/ntfs.c +++ b/tsk/fs/ntfs.c @@ -37,7 +37,7 @@ /* Macro to pass in both the epoch time value and the nano time value */ -#define WITHNANO(x) x, x##_nano +#define WITHNANO(x) x, (unsigned int)x##_nano /* mini-design note: @@ -219,7 +219,7 @@ ntfs_dinode_lookup(NTFS_INFO * a_ntfs, char *a_buf, TSK_INUM_T a_mftnum) data_run != NULL; data_run = data_run->next) { /* Test for possible overflows / error conditions */ - if ((offset < 0) || (data_run->len >= LLONG_MAX / a_ntfs->csize_b)){ + if ((offset < 0) || (data_run->len >= (TSK_DADDR_T)(LLONG_MAX / a_ntfs->csize_b))){ tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_INODE_COR); tsk_error_set_errstr @@ -293,7 +293,7 @@ ntfs_dinode_lookup(NTFS_INFO * a_ntfs, char *a_buf, TSK_INUM_T a_mftnum) ssize_t cnt; /* read the first part into mft */ cnt = tsk_fs_read(&a_ntfs->fs_info, mftaddr_b, a_buf, mftaddr_len); - if (cnt != mftaddr_len) { + if (cnt != (ssize_t)mftaddr_len) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); @@ -309,7 +309,7 @@ ntfs_dinode_lookup(NTFS_INFO * a_ntfs, char *a_buf, TSK_INUM_T a_mftnum) (&a_ntfs->fs_info, mftaddr2_b, (char *) ((uintptr_t) a_buf + (uintptr_t) mftaddr_len), a_ntfs->mft_rsize_b - mftaddr_len); - if (cnt != a_ntfs->mft_rsize_b - mftaddr_len) { + if (cnt != (ssize_t)(a_ntfs->mft_rsize_b - mftaddr_len)) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); @@ -1530,7 +1530,7 @@ ntfs_file_read_special(const TSK_FS_ATTR * a_fs_attr, "ntfs_file_read_special: Returning 0s for read past end of initsize (%" PRIuINUM ")\n", a_fs_attr->fs_file->meta->addr); - if (a_offset + a_len > a_fs_attr->nrd.allocsize) + if (a_offset + (TSK_OFF_T)a_len > a_fs_attr->nrd.allocsize) len = (ssize_t) (a_fs_attr->nrd.allocsize - a_offset); else len = (ssize_t) a_len; @@ -1777,7 +1777,7 @@ ntfs_proc_attrseq(NTFS_INFO * ntfs, } /* Copy the name and convert it to UTF8 */ - if ((attr->nlen) && (tsk_getu16(fs->endian, attr->name_off) + attr->nlen * 2 < tsk_getu32(fs->endian, attr->len))) { + if ((attr->nlen) && (tsk_getu16(fs->endian, attr->name_off) + attr->nlen * (unsigned int)2 < tsk_getu32(fs->endian, attr->len))) { int i; UTF8 *name8; UTF16 *name16; @@ -3657,7 +3657,7 @@ ntfs_load_secure(NTFS_INFO * ntfs) cnt = tsk_fs_attr_read(fs_attr_sii, 0, sii_buffer.buffer, sii_buffer.size, TSK_FS_FILE_READ_FLAG_NONE); - if (cnt != sii_buffer.size) { + if (cnt != (ssize_t)sii_buffer.size) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error reading $Secure:$SII attribute: %s\n", @@ -3720,7 +3720,7 @@ ntfs_load_secure(NTFS_INFO * ntfs) tsk_fs_attr_read(fs_attr_sds, 0, ntfs->sds_data.buffer, ntfs->sds_data.size, TSK_FS_FILE_READ_FLAG_NONE); - if (cnt != ntfs->sds_data.size) { + if (cnt != (ssize_t)ntfs->sds_data.size) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error reading $Secure:$SDS attribute: %s\n", @@ -3898,7 +3898,7 @@ ntfs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_FS_META_WALK_CB a_action, void *ptr) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; - int myflags; + unsigned int myflags; TSK_INUM_T mftnum; TSK_FS_FILE *fs_file; TSK_INUM_T end_inum_tmp; diff --git a/tsk/fs/ntfs_dent.cpp b/tsk/fs/ntfs_dent.cpp index ccbe67d653c04998a7b0eb194fa827b1a864e68a..e222d5be021b42c56572e221ba36b0c79007e20d 100644 --- a/tsk/fs/ntfs_dent.cpp +++ b/tsk/fs/ntfs_dent.cpp @@ -218,6 +218,7 @@ ntfs_parent_act(TSK_FS_FILE * fs_file, void * /*ptr*/) if ((fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) && fs_file->meta->type == TSK_FS_META_TYPE_REG) { + // @@@ This doesn't seem to be used anywhere.... if (ntfs->alloc_file_count == -1) ntfs->alloc_file_count = 1; else diff --git a/tsk/fs/tsk_ntfs.h b/tsk/fs/tsk_ntfs.h index 2045ba4e1c5dec75face05bb7c78364c128d1f98..f08a4785362ba104adbc2761d3fe2543d93f9915 100644 --- a/tsk/fs/tsk_ntfs.h +++ b/tsk/fs/tsk_ntfs.h @@ -730,7 +730,7 @@ extern "C" { NTFS_SXX_BUFFER sds_data; // (r/w shared - lock) #endif - uint32_t alloc_file_count; // number of allocated regular files, will be -1 + int alloc_file_count; // number of allocated regular files, will be -1 // until a directory is opened. NTFS_USNJINFO *usnjinfo; // update sequence number journal } NTFS_INFO; diff --git a/tsk/fs/unix_misc.c b/tsk/fs/unix_misc.c index 85ff4d4d292ba06974ee6caed6be61789d57e0ee..3f114c8a2c7b2f88b8fc585bb4f423c5cb10bae7 100644 --- a/tsk/fs/unix_misc.c +++ b/tsk/fs/unix_misc.c @@ -122,7 +122,6 @@ unix_make_data_run_indirect(TSK_FS_INFO * fs, TSK_FS_ATTR * fs_attr, TSK_FS_ATTR * fs_attr_indir, char *buf[], int level, TSK_DADDR_T addr, TSK_OFF_T length) { - char *myname = "unix_make_data_run_indirect"; size_t addr_cnt = 0; TSK_DADDR_T *myaddrs = (TSK_DADDR_T *) buf[level]; TSK_OFF_T length_remain = length; @@ -132,7 +131,7 @@ unix_make_data_run_indirect(TSK_FS_INFO * fs, TSK_FS_ATTR * fs_attr, TSK_FS_ATTR_RUN *data_run; if (tsk_verbose) - tsk_fprintf(stderr, "%s: level %d block %" PRIuDADDR "\n", myname, + tsk_fprintf(stderr, "%s: level %d block %" PRIuDADDR "\n", "unix_make_data_run_indirect", level, addr); // block_size is a fragment size in UFS, so we need to maintain length in fragments @@ -174,7 +173,7 @@ unix_make_data_run_indirect(TSK_FS_INFO * fs, TSK_FS_ATTR * fs_attr, ssize_t cnt; // read the data into the scratch buffer cnt = tsk_fs_read_block(fs, addr, buf[0], fs_bufsize); - if (cnt != fs_bufsize) { + if (cnt != (ssize_t)fs_bufsize) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); @@ -250,7 +249,6 @@ tsk_fs_unix_make_data_run(TSK_FS_FILE * fs_file) TSK_OFF_T length = 0; TSK_OFF_T read_b = 0; TSK_FS_ATTR *fs_attr; - TSK_FS_ATTR *fs_attr_indir; TSK_FS_META *fs_meta = fs_file->meta; TSK_FS_INFO *fs = fs_file->fs_info; @@ -267,14 +265,15 @@ tsk_fs_unix_make_data_run(TSK_FS_FILE * fs_file) && (fs_meta->attr_state == TSK_FS_META_ATTR_STUDIED)) { return 0; } - else if (fs_meta->attr_state == TSK_FS_META_ATTR_ERROR) { + if (fs_meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } + // not sure why this would ever happen, but... - else if (fs_meta->attr != NULL) { + if (fs_meta->attr != NULL) { tsk_fs_attrlist_markunused(fs_meta->attr); } - else if (fs_meta->attr == NULL) { + else { fs_meta->attr = tsk_fs_attrlist_alloc(); } @@ -325,6 +324,7 @@ tsk_fs_unix_make_data_run(TSK_FS_FILE * fs_file) int numSingIndirect = 0; int numDblIndirect = 0; int numTripIndirect = 0; + TSK_FS_ATTR *fs_attr_indir; /* With FFS/UFS a full block contains the addresses, but block_size is diff --git a/tsk/img/aff.c b/tsk/img/aff.c index 81f02f32effe7b92a39c3334719e8d1c294e9a75..6e4b786709a9161fa192e3be88b337b2c0a86df1 100644 --- a/tsk/img/aff.c +++ b/tsk/img/aff.c @@ -38,7 +38,7 @@ aff_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) } if (aff_info->seek_pos != offset) { - if (af_seek(aff_info->af_file, offset, SEEK_SET) != offset) { + if (af_seek(aff_info->af_file, offset, SEEK_SET) != (uint64_t)offset) { tsk_error_reset(); // @@@ ADD more specific error messages tsk_error_set_errno(TSK_ERR_IMG_SEEK); @@ -66,7 +66,7 @@ aff_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) // @@@ We could improve this if there is an AFF call // to see if the data exists or not if ((af_eof(aff_info->af_file) == 0) && - (offset + len < img_info->size)) { + (offset + (TSK_OFF_T)len < img_info->size)) { memset(buf, 0, len); cnt = len; } diff --git a/tsk/img/img_types.c b/tsk/img/img_types.c index 9897299ddf1286cf6cb7619d8625ec2619d59c6e..5a36a76cd160507df2f8c9c21c5ca24f831c140b 100644 --- a/tsk/img/img_types.c +++ b/tsk/img/img_types.c @@ -46,7 +46,7 @@ static IMG_TYPES img_open_table[] = { #if HAVE_LIBVHDI {"vhd", TSK_IMG_TYPE_VHD_VHD, "Virtual Hard Drive (Microsoft)"}, #endif - {0}, + {0,0,""}, }; diff --git a/tsk/img/raw.c b/tsk/img/raw.c index 6bb034b9688e59d779f35f6cba54c78efbcf7554..139e7920c8ebe3d43b637e8fe92c13e86199565a 100644 --- a/tsk/img/raw.c +++ b/tsk/img/raw.c @@ -149,7 +149,7 @@ raw_read_segment(IMG_RAW_INFO * raw_info, int idx, char *buf, //For physical drive when the buffer is larger than remaining data, // WinAPI ReadFile call returns -1 //in this case buffer of exact length must be passed to ReadFile - if ((raw_info->is_winobj) && (rel_offset + len > raw_info->img_info.size )) + if ((raw_info->is_winobj) && (rel_offset + (TSK_OFF_T)len > raw_info->img_info.size )) len = (size_t)(raw_info->img_info.size - rel_offset); if (FALSE == ReadFile(cimg->fd, buf, (DWORD) len, &nread, NULL)) { @@ -167,7 +167,7 @@ raw_read_segment(IMG_RAW_INFO * raw_info, int idx, char *buf, // We need to check if we've reached the end of a file and set nread to // the number of bytes read. if ((raw_info->is_winobj) && (nread == 0) && (rel_offset + len == raw_info->img_info.size)) { - nread = len; + nread = (DWORD)len; } cnt = (ssize_t) nread; diff --git a/tsk/img/tsk_img.h b/tsk/img/tsk_img.h index b412116028746cb3f041fa57f6d0772accee22f5..131f23c3354773544b81b1e445a2187255d2581f 100644 --- a/tsk/img/tsk_img.h +++ b/tsk/img/tsk_img.h @@ -69,7 +69,7 @@ extern "C" { TSK_IMG_TYPE_VHD_VHD = 0x0100, ///< VHD version TSK_IMG_TYPE_EXTERNAL = 0x1000, ///< external defined format which at least implements TSK_IMG_INFO, used by pytsk - TSK_IMG_TYPE_UNSUPP = 0xffff, ///< Unsupported disk image type + TSK_IMG_TYPE_UNSUPP = 0xffff ///< Unsupported disk image type } TSK_IMG_TYPE_ENUM; #define TSK_IMG_INFO_CACHE_NUM 32 diff --git a/tsk/vs/mm_types.c b/tsk/vs/mm_types.c index 178c4e7a3134a62f3d6802cc578375afc9343784..9cfd1370d87916b2b471ca265a01d23800699511 100644 --- a/tsk/vs/mm_types.c +++ b/tsk/vs/mm_types.c @@ -29,7 +29,7 @@ VS_TYPES vs_open_table[] = { {"sun", TSK_VS_TYPE_SUN, "Sun Volume Table of Contents (Solaris)"}, {"gpt", TSK_VS_TYPE_GPT, "GUID Partition Table (EFI)"}, - {0}, + {0, 0, ""}, }; /** diff --git a/unit_tests/base/Makefile.am b/unit_tests/base/Makefile.am index dcb1633103ca83aa21fc5d5d4bc19dbefa229b38..2eb67c711abdc5b4fbf1e74327cfd57392ce3554 100644 --- a/unit_tests/base/Makefile.am +++ b/unit_tests/base/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = -I../.. $(CPPUNIT_CFLAGS) +AM_CXXFLAGS += -Wno-unused-command-line-argument LDADD = ../../tsk/libtsk.la $(CPPUNIT_LIBS) LDFLAGS = -static