Fixes a seg-fault when displaying the time data for a corrupt archive.

PR binutuls/17605
	* bucomm.c (print_arelt_descr): Check for ctime returning NULL.
This commit is contained in:
Nick Clifton 2014-11-18 17:35:39 +00:00
parent 8435453b81
commit 0593bd3ace
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2014-11-18 Nick Clifton <nickc@redhat.com>
PR binutuls/17605
* bucomm.c (print_arelt_descr): Check for ctime returning NULL.
2014-11-18 Nick Clifton <nickc@redhat.com>
PR binutils/17512

View File

@ -429,8 +429,12 @@ print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose)
const char *ctime_result = (const char *) ctime (&when);
bfd_size_type size;
/* POSIX format: skip weekday and seconds from ctime output. */
sprintf (timebuf, "%.12s %.4s", ctime_result + 4, ctime_result + 20);
/* PR binutils/17605: Check for corrupt time values. */
if (ctime_result == NULL)
sprintf (timebuf, _("<time data corrupt>"));
else
/* POSIX format: skip weekday and seconds from ctime output. */
sprintf (timebuf, "%.12s %.4s", ctime_result + 4, ctime_result + 20);
mode_string (buf.st_mode, modebuf);
modebuf[10] = '\0';