Re: [PATCH] segfault-on-invalid-mtime fix

2008-12-29 Thread Miguel de Icaza
Hello,

This patch looks good, but there are two uses of strftime as well,
it might make sense to wrap the use of strftime in a new routine that
always make this check (when localtime returns NULL).


 mc-4.6.1/src/util.c

___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [PATCH] segfault-on-invalid-mtime fix

2008-12-29 Thread Enrico Weigelt
* Miguel de Icaza mig...@novell.com schrieb:

Hi,

 This patch looks good, but there are two uses of strftime as well,
 it might make sense to wrap the use of strftime in a new routine that
 always make this check (when localtime returns NULL).

I'm working on that.

BTW: we've got some situations where precense of strftime() is
checked (HAVE_STRFTIME) and fallback to ctime(), and some where
it is NOT. 

Should we always do the #ifdef or completely drop the fallback ? 


cu
-- 
-
 Enrico Weigelt==   metux IT service - http://www.metux.de/
-
 Please visit the OpenSource QM Taskforce:
http://wiki.metux.de/public/OpenSource_QM_Taskforce
 Patches / Fixes for a lot dozens of packages in dozens of versions:
http://patches.metux.de/
-
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


[PATCH] segfault-on-invalid-mtime fix

2008-12-25 Thread Enrico Weigelt


-- 
-
 Enrico Weigelt==   metux IT service - http://www.metux.de/
-
 Please visit the OpenSource QM Taskforce:
http://wiki.metux.de/public/OpenSource_QM_Taskforce
 Patches / Fixes for a lot dozens of packages in dozens of versions:
http://patches.metux.de/
-
#
# 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 ma...@office.modum.by
# Reported-Bug: http://bugs.gentoo.org/184296
# Submit-By:Enrico Weigelt, metux IT service weig...@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
--- mc-4.6.1.orig/src/util.c2008-12-26 02:19:54.0 +0100
+++ mc-4.6.1/src/util.c 2008-12-26 03:13:13.0 +0100
@@ -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;
 }
 
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel