summaryrefslogtreecommitdiffstats
path: root/abs/extra/mc/mc-4.6.1-invalid-mtime.patch
blob: 07b1f6d1c169fb756ea02c394007edea6d4669cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

  Invalid timestamps on files caused mc to segfault by passing a null
  pointer to strftime. Avoid trying to print the time in this case.

  Reported by Maxim Britov <maxim@office.modum.by>
  at http://bugs.gentoo.org/184296

--- mc-4.6.1/src/util.c
+++ mc-4.6.1/src/util.c
@@ -717,6 +717,7 @@
     static size_t i18n_timelength = 0;
     static const char *fmtyear, *fmttime;
     const char *fmt;
+    struct tm *whentm;
 
     if (i18n_timelength == 0){
 	i18n_timelength = i18n_checktimelength() + 1;
@@ -740,7 +741,11 @@
     else
 	fmt = fmttime;
     
-    strftime (timebuf, i18n_timelength, fmt, localtime(&when));
+    whentm = localtime(&when);
+    if (whentm == NULL)
+	return "(invalid)";
+
+    strftime (timebuf, i18n_timelength, fmt, whentm);
     return timebuf;
 }