1Description: Use proper time_t type instead of unsigned long for variables
2 that are being passed to localhost() and gmtime(). This fixes several
3 segfaults on x32.
4Author: Guillem Jover <guillem@debian.org>
5Origin: vendor
6Forwarded: no
7Last-Update: 2019-08-11
8
9---
10 arjtypes.c |   17 +++++++++--------
11 1 file changed, 9 insertions(+), 8 deletions(-)
12
13--- a/arjtypes.c
14+++ b/arjtypes.c
15@@ -135,11 +135,11 @@ static int isleapyear(int year)
16
17 /* Converts a UNIX timestamp to the DOS style */
18
19-static unsigned long ts_unix2dos(const long ts)
20+static unsigned long ts_unix2dos(time_t ts)
21 {
22  struct tm *stm;
23
24- stm=arj_localtime((time_t*)&ts);
25+ stm=arj_localtime(&ts);
26  return(get_tstamp(stm->tm_year+1900, stm->tm_mon+1, stm->tm_mday,
27         stm->tm_hour, stm->tm_min, stm->tm_sec));
28 }
29@@ -148,14 +148,14 @@ static unsigned long ts_unix2dos(const l
30
31 static unsigned long mk_unixtime(int y, int m, int d, int hh, int mm, int ss)
32 {
33- unsigned long u=0, ts;
34+ unsigned long u=0;
35  unsigned int i, v;
36  /* Clash with NetBSD/x86-64 patch: leaving rc as unsigned long still permits
37     to escape the year 2038 problem in favor of year 2106 problem, while a
38     dedicated time_t structure can be expected as a 64-bit value on relevant
39     platforms -- ASR fix 25/01/2004 */
40- unsigned long rc;
41- time_t tt;
42+ time_t rc;
43+ time_t tt, ts;
44  long tzshift, shiftd1, shiftd2;
45  struct tm *stm;
46
47@@ -191,7 +191,7 @@ static unsigned long mk_unixtime(int y,
48    u+=isleapyear(y);
49  }
50  rc=86400*(unsigned long)(u+d-1)+(unsigned long)hh*3600+(unsigned long)mm*60+(unsigned long)ss;
51- stm=arj_localtime((const long *)&rc);
52+ stm=arj_localtime(&rc);
53  debug_assert(stm!=NULL);               /* LIBCS.DLL returns NULL for unixtime beyond
54                                            0x7FFFFFFF */
55  tzshift=(long)stm->tm_hour*3600+(long)stm->tm_min*60;
56@@ -203,7 +203,7 @@ static unsigned long mk_unixtime(int y,
57   debug_assert(stm!=NULL);
58   stm->tm_year+=v;
59  #else
60-  stm=gmtime((const long *)&ts);
61+  stm=gmtime(&ts);
62  #endif
63  shiftd2=stm->tm_mday;
64  /* Local time overruns GMT, add 24 hours for safety */
65@@ -304,8 +304,9 @@ void make_timestamp(struct timestamp *de
66 void timestamp_to_str(char *str, struct timestamp *ts)
67 {
68  struct tm *stm;
69+ time_t ut = ts->unixtime;
70
71- stm=arj_localtime((time_t *)&ts->unixtime);
72+ stm=arj_localtime(&ut);
73  /* Workaround for a MS C v 7.0 CRT bug */
74  #if TARGET==DOS&&COMPILER==MSC&&_MSC_VER==700
75   if(stm->tm_year<70)                   /* 31 -> 101 */
76