summaryrefslogtreecommitdiffstats
path: root/src/askloc.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-01-25 13:34:21 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-01-25 13:34:21 +0100
commit6690fdd45ff41ae44e20ca72dfb2afab39010894 (patch)
tree09b030e2a7b2ae066af0e4c623491ad38624d4ec /src/askloc.c
parent88d86389d5ba46bebb353e81f3ed617b9864b7c9 (diff)
Avoid additional NULL pointer derefence when localtime() failed
Diffstat (limited to 'src/askloc.c')
-rw-r--r--src/askloc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/askloc.c b/src/askloc.c
index 3dc41fd..a74ce47 100644
--- a/src/askloc.c
+++ b/src/askloc.c
@@ -299,7 +299,7 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
int offset=0;
int pos_num=0;
int old_LINES=0;
- int old_COLS=0;
+ int old_COLS=1;
do
{
int dst_directory_ok=0;
@@ -573,17 +573,18 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
static void dir_aff_entry(WINDOW *window, file_info_t *file_info)
{
char str[11];
- char datestr[80];
- if(file_info->td_mtime!=0)
+ char datestr[80];
{
- const struct tm *tm_p= localtime(&file_info->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);
- /* May have to use %d instead of %e */
- } else {
- strncpy(datestr, " ",sizeof(datestr));
+ const struct tm *tm_p;
+ if(file_info->td_mtime!=0 && (tm_p= localtime(&file_info->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(file_info->st_mode, str);
wprintw(window, "%s %5u %5u ",