From 9c92647ee3accffacd5b42ac368ec9267bef405e Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Mon, 19 Apr 2021 20:06:49 +0200 Subject: [PATCH] Changes to force TZ to UTC #75 --- class_parser.py | 2 +- dpkg/changelog | 4 ++-- tsk3.cpp | 21 ++++++++++++++++++++- version.txt | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/class_parser.py b/class_parser.py index a60f1a9..fbd9332 100644 --- a/class_parser.py +++ b/class_parser.py @@ -235,7 +235,7 @@ DEBUG = 0 # The pytsk3 version. -VERSION = "20210327" +VERSION = "20210419" # These functions are used to manage library memory. FREE = "aff4_free" diff --git a/dpkg/changelog b/dpkg/changelog index e538ff8..49db45f 100644 --- a/dpkg/changelog +++ b/dpkg/changelog @@ -1,5 +1,5 @@ -pytsk3 (20210327-1) unstable; urgency=low +pytsk3 (20210419-1) unstable; urgency=low * Auto-generated - -- Joachim Metz Sat, 27 Mar 2021 13:12:25 -0100 + -- Joachim Metz Mon, 19 Apr 2021 20:05:49 -0100 diff --git a/tsk3.cpp b/tsk3.cpp index f67586e..18eca45 100644 --- a/tsk3.cpp +++ b/tsk3.cpp @@ -14,14 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "tsk3.h" +#include + #if defined( TSK_MULTITHREAD_LIB ) + extern "C" { extern void tsk_init_lock(tsk_lock_t * lock); extern void tsk_deinit_lock(tsk_lock_t * lock); } -#endif + +#endif /* defined( TSK_MULTITHREAD_LIB ) */ /* Prototypes for IMG_INFO hooks * Note that IMG_INFO_read is called by the SleuthKit the Img_Info_read @@ -690,6 +695,20 @@ 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); diff --git a/version.txt b/version.txt index b667f88..23ecfbe 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20210327 \ No newline at end of file +20210419 \ No newline at end of file