summaryrefslogtreecommitdiff
path: root/archivers/zoo/patches/patch-ai
blob: e6bd4bd9fec20cb57fe6b9c49d911d0082b82744 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$NetBSD: patch-ai,v 1.4 2009/04/25 23:46:47 gdt Exp $

--- zoolist.c.orig	1991-07-20 00:57:27.000000000 +0200
+++ zoolist.c
@@ -21,7 +21,7 @@ Copyright (C) 1986, 1987 Rahul Dhesi -- 
 #include "options.h"
 #include "portable.h"
 #include "zoomem.h"  /* to get ZOOCOUNT */
-
+#include <time.h>
 /* Lists files in archive */
 #include "zoo.h"
 #include "errors.i"
@@ -92,6 +92,7 @@ int genson = 1;					/* enable/disable ge
 int show_mode = 0;				/* show file protection */
 #endif
 int first_dir = 1;				/* if first direntry -- to adjust dat_ofs */
+unsigned long zoo_pointer = 0;         /* Track our position in the file */
 
 while (*option) {
    switch (*option) {
@@ -211,6 +212,9 @@ if (fiz_ofs != 0L) {                /* i
 		show_acmt (&zoo_header, zoo_file, 0);		/* show archive comment */
 	}
 
+   /* Begin tracking our position in the file */
+   zoo_pointer = zoo_header.zoo_start;
+
    /* Seek to the beginning of the first directory entry */
    if (zooseek (zoo_file, zoo_header.zoo_start, 0) != 0) {
       ercount++;
@@ -414,7 +418,7 @@ if (fiz_ofs != 0L) {                /* i
 					if (direntry.fattr == 0)
 						printf ("--- ");
 					else if ((direntry.fattr >> 22) == 1)
-						printf ("%03o ", direntry.fattr & 0x1ff);
+						printf ("%03o ", (unsigned int)direntry.fattr & 0x1ff);
 					else
 						printf ("??? ");
 				}
@@ -437,6 +441,11 @@ if (fiz_ofs != 0L) {                /* i
          if (verb_list && !fast)
             show_comment (&direntry, zoo_file, 0, (char *) NULL);
       } /* end if (lots of conditions) */
+
+      /* Make sure we are not seeking to already processed data */
+      if (direntry.next <= zoo_pointer)
+               prterror ('f', "ZOO chain structure is corrupted\n");
+      zoo_pointer = direntry.next;
    
 		/* ..seek to next dir entry */
       zooseek (zoo_file, direntry.next, 0);
@@ -539,10 +548,12 @@ int file_tz;
 {
 	long gettz();
 	int diff_tz;				/* timezone difference */
+	time_t t;
 	if (file_tz == NO_TZ) 	/* if no timezone stored ..*/
 		printf ("   ");			/* .. just pad with blanks */
 	else {
-		diff_tz = (file_tz / 4) - (int) (gettz() / 3600);
+		time(&t);
+		diff_tz = (file_tz / 4) - (int) (gettz(t) / 3600);
 		if (diff_tz == 0)
 			printf ("   ");					/* print nothing if same */
 		else if (diff_tz > 0)			/* else print signed difference */