From 7c91cdd89e4316c45b6fa1ea4830f4c2c879f773 Mon Sep 17 00:00:00 2001 From: Salvador Cuñat Date: Sun, 22 Jan 2017 13:43:10 +0100 Subject: smtk-import-Fix crash due to localization issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Libmdbº:xturns localized strings while parsing the data bases. This is bad for time calculations as we may end with different strings formats (e.g. en_US vs almost the rest of the world). Solution is simple: set a fixed locale and parse only this format. Signed-off-by: Salvador Cuñat --- smtk-import/smartrak.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index 25df0901c..e102c1abd 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "core/dive.h" #include "core/gettext.h" @@ -104,7 +105,7 @@ static void smtk_time_to_tm(char *t_buffer, struct tm *tm_date) { char *temp = NULL; - temp = rindex(copy_string(t_buffer), ' '); + temp = index(copy_string(t_buffer), ' '); if (temp) strptime(temp, "%X", tm_date); } @@ -655,10 +656,11 @@ void smartrak_import(const char *file, struct dive_table *divetable) MdbHandle *mdb, *mdb_clon; MdbTableDef *mdb_table; MdbColumn *col[MDB_MAX_COLS]; - char *bound_values[MDB_MAX_COLS]; int i, dc_model; + // Set an european style locale to work date/time conversion + setlocale(LC_TIME, "POSIX"); mdb = mdb_open(file, MDB_NOFLAGS); if (!mdb) { report_error("[Error][smartrak_import]\tFile %s does not seem to be an Access database.", file); -- cgit v1.2.3-70-g09d2