Skip to content

Commit

Permalink
Changed FAT mktime work-around to sleuthkit patch (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 7, 2024
1 parent da38446 commit 19951e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
18 changes: 18 additions & 0 deletions patches/sleuthkit-4.12.1-fatfs_utils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/tsk/fs/fatfs_utils.c b/tsk/fs/fatfs_utils.c
index 9495ac923..440b0dff8 100755
--- a/tsk/fs/fatfs_utils.c
+++ b/tsk/fs/fatfs_utils.c
@@ -179,8 +179,11 @@ fatfs_dos_2_unix_time(uint16_t date, uint16_t time, uint8_t timetens)
* it out */
tm1.tm_isdst = -1;

- ret = mktime(&tm1);
-
+#if defined( _MSC_VER )
+ ret = _mkgmtime(&tm1);
+#else
+ ret = timegm(&tm1);
+#endif
if (ret < 0) {
if (tsk_verbose)
tsk_fprintf(stderr,
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ def patch_sleuthkit(self):
fd.write(data)

patch_files = [
"sleuthkit-{0:s}-configure.ac".format(self._SLEUTHKIT_GIT_TAG)]
"sleuthkit-{0:s}-configure.ac".format(self._SLEUTHKIT_GIT_TAG),
"sleuthkit-{0:s}-fatfs_utils.c".format(self._SLEUTHKIT_GIT_TAG)]

for patch_file in patch_files:
patch_file = os.path.join("patches", patch_file)
Expand Down
14 changes: 0 additions & 14 deletions tsk3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,20 +695,6 @@ VIRTUAL(Volume_Info, Object) {


void tsk_init() {

// libtsk uses mktime and localtime that rely on the TZ environment variable
// however that leads to inconsistent behavior with different TZ values.
// Hence that we force TZ to be UTC, when possible.
#if defined( _MSC_VER )
_putenv_s("TZ", "UTC");
_tzset();

// Some installations of MinGW do not support setenv
#elif !defined( __MINGW32__ )
setenv("TZ", "UTC", 1);
tzset();
#endif

//tsk_verbose++;
Img_Info_init((Object)&__Img_Info);
FS_Info_init((Object)&__FS_Info);
Expand Down

0 comments on commit 19951e3

Please sign in to comment.