Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check return value of localtime
Dereferencing this value before checking it may result in a null
pointer dereference (segfault)
  • Loading branch information
t-richards committed May 5, 2018
1 parent c11f287 commit 8a67a8c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions utils/show.c
Expand Up @@ -114,8 +114,15 @@ static void showInfo(tr_info const* inf)
}
else
{
struct tm tm = *localtime(&inf->dateCreated);
printf(" Created on: %s", asctime(&tm));
struct tm *created_on = localtime(&inf->dateCreated);
if (created_on == NULL)
{
printf(" Created on: Invalid date\n");
}
else
{
printf(" Created on: %s", asctime(created_on));
}
}

if (inf->comment != NULL && *inf->comment != '\0')
Expand Down

0 comments on commit 8a67a8c

Please sign in to comment.