#
# Invalid timestamps on files caused mc to segfault by passing a null
# pointer to strftime. Avoid trying to print the time in this case.
#
# Source: Gentoo Portage
# Reference: mc-4.6.1
# Reported-By: Maxim Britov <maxim office modum by>
# Reported-Bug: <a rel="nofollow" href="http://bugs.gentoo.org/184296">http://bugs.gentoo.org/184296</a>
# Submit-By: Enrico Weigelt, metux IT service <weigelt metux de>
# Submit-Date: 2008-12-26
# State: new
#
diff -ruN mc-4.6.1.orig/src/util.c mc-4.6.1/src/util.c
old
|
new
|
|
717 | 717 | static size_t i18n_timelength = 0; |
718 | 718 | static const char *fmtyear, *fmttime; |
719 | 719 | const char *fmt; |
| 720 | struct tm *whentm; |
720 | 721 | |
721 | 722 | if (i18n_timelength == 0){ |
722 | 723 | i18n_timelength = i18n_checktimelength() + 1; |
… |
… |
|
740 | 741 | else |
741 | 742 | fmt = fmttime; |
742 | 743 | |
743 | | strftime (timebuf, i18n_timelength, fmt, localtime(&when)); |
| 744 | whentm = localtime(&when); |
| 745 | if (whentm == NULL) |
| 746 | return "(invalid)"; |
| 747 | |
| 748 | strftime (timebuf, i18n_timelength, fmt, whentm); |
744 | 749 | return timebuf; |
745 | 750 | } |
746 | 751 | |