summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-09-06 19:48:29 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-09-06 19:48:29 +0200
commit90cdd0bd88b4f690871017daa21e04a9bb3e99b2 (patch)
tree8876259f9a7f9b688b98cca543689491f3ce6a8c
parent74f7cf79a3eb3b6b29609412a1f05de94b9bc9a4 (diff)
fidentify: report time using localtime instead of seconds since epoch
-rw-r--r--src/fidentify.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/fidentify.c b/src/fidentify.c
index 883e76a..e345273 100644
--- a/src/fidentify.c
+++ b/src/fidentify.c
@@ -129,10 +129,14 @@ static int file_identify(const char *filename, const unsigned int options)
if(file_recovery_new.file_stat!=NULL &&
file_recovery_new.file_stat->file_hint!=NULL &&
file_recovery_new.file_check!=NULL &&
+#ifdef __FRAMAC__
+ file_recovery_new.extension != NULL &&
+#endif
((options&OPT_CHECK)!=0 || ((options&OPT_TIME)!=0 && file_recovery_new.time==0))
)
{
off_t file_size;
+ /*@ assert valid_read_string(file_recovery_new.extension); */
file_recovery_new.handle=file;
my_fseek(file_recovery_new.handle, 0, SEEK_END);
#if defined(HAVE_FTELLO)
@@ -155,8 +159,25 @@ static int file_identify(const char *filename, const unsigned int options)
file_recovery_new.extension:file_recovery_new.file_stat->file_hint->description));
if((options&OPT_CHECK)!=0 && file_recovery_new.file_check!=NULL)
printf(" file_size=%llu", (long long unsigned)file_recovery_new.file_size);
- if((options&OPT_TIME)!=0 && file_recovery_new.time!=0)
- printf(" time=%llu", (long long unsigned)file_recovery_new.time);
+ if((options&OPT_TIME)!=0 && file_recovery_new.time!=0 && file_recovery_new.time!=(time_t)-1)
+#ifdef __FRAMAC__
+ {
+ printf(" time=%lld", (long long)file_recovery_new.time);
+ }
+#else
+ {
+ char outstr[200];
+#if defined(__MINGW32__) || defined(__FRAMAC__)
+ const struct tm *tmp = localtime(&file_recovery_new.time);
+#else
+ struct tm tm_tmp;
+ const struct tm *tmp = localtime_r(&file_recovery_new.time,&tm_tmp);
+#endif
+ if(tmp != NULL &&
+ strftime(outstr, sizeof(outstr), "%Y-%m-%dT%H:%M:%S%z", tmp) != 0)
+ printf(" time=%s", &outstr[0]);
+ }
+#endif
printf("\n");
}
else