[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#403245: dvipdfm(x) crashes in some timezones



Dear dvipdfmx developers, dear dvipdfmx maintainer in Debian,

in the last weeks, we found that dvipdfm(x) would segfault when launched
in timezones with half-hour offset to UTC, and Mark Wicks wrote a
patch.  It would be nice if this could be applied to dvipdfmx, too.

For Debian, it would be even nicer if the patch could make it into etch
(and since the RMs allowed fixed tetex-bin and texlive-bin in, it's
likely that dvipdfmx will get a freeze exception, too).  Yu, will you
have time for an upload?  Or would you mind an NMU?

Below is an updated patch.

Regards, Frank


#! /bin/sh /usr/share/dpatch/dpatch-run
## 61_dvipdfm_timezone.dpatch by "Mark A. Wicks" <mwicks@kettering.edu>
##
## DP: fix crash of dvipdfm with 0.5 timezones

@DPATCH@
--- ./build/TeX/texk/dvipdfm/pdfdoc.c.orig	2003-01-28 00:18:05.000000000 +0100
+++ ./build/TeX/texk/dvipdfm/pdfdoc.c	2007-01-04 00:43:19.000000000 +0100
@@ -232,13 +232,7 @@
 
 static char *asn_date (void)
 {
-#ifndef HAVE_TIMEZONE
-  #ifdef TM_GM_TOFF
-     #define timezone (bdtime->gm_toff)
-  #else
-     #define timezone 0l
-#endif /* TM_GM_TOFF */
-#endif /* HAVE_TIMEZONE */
+  long tz_offset;
   static char date_string[24];
   time_t current_time;
   struct tm *bd_time;
@@ -247,10 +241,28 @@
   }
   time(&current_time);
   bd_time = localtime(&current_time);
-  sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%+03ld'%02ld'",
-	   bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
-	   bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
-	   -timezone/3600, timezone%3600);
+
+#ifdef HAVE_TM_GMTOFF  /* Preferred way to get time zone offset */
+  tz_offset = bd_time->tm_gmtoff;
+#else
+#ifdef HAVE_TIMEZONE   /* Plan B --- use external variable 'timezone'
+                       /* (may not provide correct offset for daylight savings time) */
+  tz_offset = - timezone;
+#else                  /* Last resort --- without more information, set offset to zero */
+  tz_offset = 0l;
+#endif /* HAVE_TIMEZONE */
+#endif /* HAVE_TM_GMTOFF */
+
+  if (tz_offset == 0l) {
+    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02dZ00'00'",
+	     bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
+	     bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec);
+  } else {
+    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%c%02ld'%02ld'",
+             bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
+             bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
+	     (tz_offset>0)? '+':'-', labs(tz_offset)/3600, (labs(tz_offset)/60)%60);
+  }
   return date_string;
 }
 


-- 
Dr. Frank Küster
Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie, Univ. Zürich
Debian Developer (teTeX/TeXLive)



Reply to: