diff --git a/tsk/fs/fs_name.c b/tsk/fs/fs_name.c index 532f8d8f5473986ee2b9a4361a1307ced04440e7..a687fcf8bb62fcd65777ecc83424cfdecf1f6edc 100755 --- a/tsk/fs/fs_name.c +++ b/tsk/fs/fs_name.c @@ -297,13 +297,13 @@ tsk_fs_meta_make_ls(const TSK_FS_META * a_fs_meta, char *a_buf, char * tsk_fs_time_to_str(time_t time, char buf[128]) { + struct tm *tmTime; + buf[0] = '\0'; - if (time <= 0) { + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { strncpy(buf, "0000-00-00 00:00:00 (UTC)", 128); } else { - struct tm *tmTime = localtime(&time); - snprintf(buf, 128, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, @@ -326,13 +326,13 @@ char * tsk_fs_time_to_str_subsecs(time_t time, unsigned int subsecs, char buf[128]) { + struct tm *tmTime; + buf[0] = '\0'; - if (time <= 0) { + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { strncpy(buf, "0000-00-00 00:00:00 (UTC)", 32); } else { - struct tm *tmTime = localtime(&time); - snprintf(buf, 64, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d.%.9d (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, @@ -368,12 +368,12 @@ tsk_fs_print_time(FILE * hFile, time_t time) static void tsk_fs_print_day(FILE * hFile, time_t time) { - if (time <= 0) { + struct tm *tmTime; + + if (time <= 0 || (tmTime = localtime(&time)) == NULL) { tsk_fprintf(hFile, "0000-00-00 00:00:00 (UTC)"); } else { - struct tm *tmTime = localtime(&time); - tsk_fprintf(hFile, "%.4d-%.2d-%.2d 00:00:00 (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday,