summaryrefslogtreecommitdiffstats
path: root/src/fat_adv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-01-25 13:30:45 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-01-25 13:30:45 +0100
commit88d86389d5ba46bebb353e81f3ed617b9864b7c9 (patch)
tree49dc3a421a8fe67402043b0c743e0d166fa70389 /src/fat_adv.c
parent59b6e0cb9751d6abc1670c58959feef945df79ec (diff)
src/fat_adv.c: NULL pointer dereference if localtime() returns NULL
Thanks to Graham Sutherland for reporting this bug
Diffstat (limited to 'src/fat_adv.c')
-rw-r--r--src/fat_adv.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 63d93f2..7a54597 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -217,15 +217,17 @@ static int ask_root_directory(disk_t *disk_car, const partition_t *partition, co
}
else
waddstr(window, " ");
- if(current_file->td_mtime!=0)
{
- const struct tm *tm_p=localtime(&current_file->td_mtime);
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- } else {
- strncpy(datestr, " ",sizeof(datestr));
+ const struct tm *tm_p;
+ if(current_file->td_mtime!=0 && (tm_p=localtime(&current_file->td_mtime))!=NULL)
+ {
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
+ }
}
mode_string(current_file->st_mode, str);
wprintw(window, "%s %3u %3u ",