View | Details | Raw Unified | Return to bug 83591
Collapse All | Expand All

(-)/home/hsn/hacked/catdoc/Makefile (-2 / +2 lines)
Lines 6-12 Link Here
6
#
6
#
7
7
8
PORTNAME=	catdoc
8
PORTNAME=	catdoc
9
PORTVERSION=	0.93.4
9
PORTVERSION=	0.94
10
CATEGORIES=	textproc
10
CATEGORIES=	textproc
11
MASTER_SITES=	ftp://ftp.45.free.net/pub/catdoc/
11
MASTER_SITES=	ftp://ftp.45.free.net/pub/catdoc/
12
#		${MASTER_SITE_TEX_CTAN:S/$/support\/catdoc\//}
12
#		${MASTER_SITE_TEX_CTAN:S/$/support\/catdoc\//}
Lines 17-23 Link Here
17
GNU_CONFIGURE=	yes
17
GNU_CONFIGURE=	yes
18
USE_GMAKE=	yes
18
USE_GMAKE=	yes
19
USE_REINPLACE=	yes
19
USE_REINPLACE=	yes
20
MAN1=		catdoc.1 wordview.1 xls2csv.1
20
MAN1=		catdoc.1 wordview.1 xls2csv.1 catppt.1
21
21
22
.if !defined(LANG) || ${LANG} != ru_RU.KOI8-R
22
.if !defined(LANG) || ${LANG} != ru_RU.KOI8-R
23
# Remove the below line to get Cyrillic code page support instead
23
# Remove the below line to get Cyrillic code page support instead
(-)/home/hsn/hacked/catdoc/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
MD5 (catdoc-0.93.4.tar.gz) = efe7e24b387444d5967fc2fc25664fb2
1
MD5 (catdoc-0.94.tar.gz) = f884dabe366d66c6cda35dacb0cdceab
2
SIZE (catdoc-0.93.4.tar.gz) = 121933
2
SIZE (catdoc-0.94.tar.gz) = 151690
(-)/home/hsn/hacked/catdoc/files/patch-ole (-226 lines)
Lines 1-226 Link Here
1
Index: src/ole.c
2
===================================================================
3
RCS file: /work/oss/catdoc/src/ole.c,v
4
retrieving revision 1.14
5
diff -u -w -b -B -r1.14 ole.c
6
--- src/ole.c	24 Dec 2003 12:20:46 -0000	1.14
7
+++ src/ole.c	26 Oct 2004 09:53:48 -0000
8
@@ -24,7 +24,7 @@
9
 
10
 #define min(a,b) ((a) < (b) ? (a) : (b))
11
 
12
-long int sectorSize;
13
+long int sectorSize, shortSectorSize;
14
 /* BBD Info */
15
 long int  bbdStart, bbdNumBlocks;
16
 unsigned char *BBD=NULL;
17
@@ -39,6 +39,14 @@
18
 
19
 static char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
20
 
21
+long int pow2(int n) {
22
+	long int acc=1,i;
23
+	for(i=0; i<n;i++)
24
+		acc*=2;
25
+	return acc;
26
+}
27
+
28
+
29
 /** 
30
  * Initializes ole structure
31
  * 
32
@@ -52,9 +60,10 @@
33
  */
34
 FILE* ole_init(FILE *f, void *buffer, size_t bufSize)  {
35
 	unsigned char oleBuf[BBD_BLOCK_SIZE];
36
+	unsigned char *tmpBuf;
37
 	FILE *newfile;
38
 	int ret=0, i;
39
-	long int sbdMaxLen, sbdCurrent, propMaxLen, propCurrent;
40
+	long int sbdMaxLen, sbdCurrent, propMaxLen, propCurrent, mblock;
41
 	oleEntry *tEntry;
42
 
43
 	/* deleting old data (if it was allocated) */
44
@@ -83,6 +92,7 @@
45
 	}	
46
 	fseek(newfile,0,SEEK_END);
47
 	fileLength=ftell(newfile);
48
+/* 	fprintf(stderr, "fileLength=%ld\n", fileLength);    */
49
 	fseek(newfile,0,SEEK_SET);
50
 	ret=fread(oleBuf,1,BBD_BLOCK_SIZE,newfile);
51
 	if ( ret != BBD_BLOCK_SIZE ) {
52
@@ -91,33 +101,61 @@
53
 	if (strncmp(oleBuf,ole_sign,8) != 0) {
54
 		return NULL;
55
 	}
56
-/* 	if ( (sectorSize = BBD_BLOCK_SIZE * getlong(oleBuf,0x40)) == 0) */
57
-	sectorSize = BBD_BLOCK_SIZE;
58
+ 	sectorSize = pow2(getshort(oleBuf,0x1e));
59
+	shortSectorSize=pow2(getshort(oleBuf,0x20));
60
 	
61
 /* Read BBD into memory */
62
 	bbdStart=getlong(oleBuf,0x4c);
63
 	bbdNumBlocks = getulong(oleBuf,0x2c);
64
-	if((BBD=malloc(bbdNumBlocks*BBD_BLOCK_SIZE)) == NULL ) {
65
+	if((BBD=malloc(bbdNumBlocks*sectorSize)) == NULL ) {
66
 		return NULL;
67
 	}
68
+	
69
+	if((tmpBuf=malloc(MSAT_ORIG_SIZE)) == NULL ) {
70
+		return NULL;
71
+	}
72
+	memcpy(tmpBuf,oleBuf+0x4c,MSAT_ORIG_SIZE);
73
+	mblock=getulong(oleBuf,0x44);
74
+	i=0;
75
+/* 	fprintf(stderr, "i=%d mblock=%ld\n", i, mblock); */
76
+	while(mblock>=0) {
77
+		char *newbuf;
78
+		if ((newbuf=realloc(tmpBuf, sectorSize+MSAT_ORIG_SIZE)) != NULL) {
79
+			tmpBuf=newbuf;
80
+		} else {
81
+			perror("BDB realloc error");
82
+			free(tmpBuf);
83
+			ole_finish();
84
+			return NULL;
85
+		}
86
+		
87
+		fseek(newfile, 512+mblock*sectorSize, SEEK_SET);
88
+		fread(tmpBuf+MSAT_ORIG_SIZE+sectorSize*i, 1, sectorSize, newfile);
89
+		i++;
90
+		mblock=getulong(tmpBuf, MSAT_ORIG_SIZE+sectorSize*i-4);
91
+/* 		fprintf(stderr, "i=%d mblock=%ld\n", i, mblock); */
92
+	};
93
+	
94
 /*   	fprintf(stderr, "bbdNumBlocks=%ld\n", bbdNumBlocks);   */
95
 	for(i=0; i< bbdNumBlocks; i++) {
96
-		long int bbdSector=getlong(oleBuf,0x4c+4*i);
97
+		long int bbdSector=getlong(tmpBuf,4*i);
98
 		
99
-		if (bbdSector >= fileLength/sectorSize) {
100
+/*  		fprintf(stderr, "bbdSector(%d)=%ld\n",i,bbdSector); */
101
+		if (bbdSector >= fileLength/sectorSize || bbdSector < 0) {
102
 			fprintf(stderr, "Bad BBD entry!\n");
103
 			ole_finish();
104
 			return NULL;
105
 		}
106
-/*  		fprintf(stderr, "bbdSector=%ld\n",bbdSector);  */
107
-		fseek(newfile, (bbdSector+1)*BBD_BLOCK_SIZE, SEEK_SET);
108
-		if ( fread(BBD+i*BBD_BLOCK_SIZE, 1, BBD_BLOCK_SIZE, newfile) !=
109
-			 BBD_BLOCK_SIZE ) {
110
+		fseek(newfile, 512+bbdSector*sectorSize, SEEK_SET);
111
+		if ( fread(BBD+i*sectorSize, 1, sectorSize, newfile) != sectorSize ) {
112
 			fprintf(stderr, "Can't read BBD!\n");
113
+			free(tmpBuf);
114
 			ole_finish();
115
 			return NULL;
116
 		}
117
 	}
118
+	free(tmpBuf);
119
+	
120
 /* Read SBD into memory */
121
 	sbdLen=0;
122
 	sbdMaxLen=10;
123
@@ -128,8 +166,8 @@
124
 			return NULL;
125
 		}
126
 		while(1) {
127
-			fseek(newfile, (sbdCurrent+1)*sectorSize, SEEK_SET);
128
-			fread(SBD+sbdLen*BBD_BLOCK_SIZE, 1, sectorSize, newfile);
129
+			fseek(newfile, 512+sbdCurrent*sectorSize, SEEK_SET);
130
+			fread(SBD+sbdLen*sectorSize, 1, sectorSize, newfile);
131
 			sbdLen++;
132
 			if (sbdLen >= sbdMaxLen) {
133
 				char *newSBD;
134
@@ -148,7 +186,7 @@
135
 				sbdCurrent >= fileLength/sectorSize)
136
 				break;
137
 		}
138
-		sbdNumber = (sbdLen*sectorSize)/SBD_BLOCK_SIZE;
139
+		sbdNumber = (sbdLen*sectorSize)/shortSectorSize;
140
 /*   		fprintf(stderr, "sbdLen=%ld sbdNumber=%ld\n",sbdLen, sbdNumber); */
141
 	} else {
142
 		SBD=NULL;
143
@@ -164,7 +202,7 @@
144
 		}
145
 		while(1) {
146
 /*  			fprintf(stderr, "propCurrent=%ld\n",propCurrent); */
147
-			fseek(newfile, (propCurrent+1)*sectorSize, SEEK_SET);
148
+			fseek(newfile, 512+propCurrent*sectorSize, SEEK_SET);
149
 			fread(properties+propLen*sectorSize,
150
 				  1, sectorSize, newfile);
151
 			propLen++;
152
@@ -279,7 +317,7 @@
153
 	if (e->startBlock >= 0 &&
154
 		e->length > 0 &&
155
 		(e->startBlock <=
156
-		 fileLength/(e->isBigBlock ? sectorSize : SBD_BLOCK_SIZE))) {
157
+		 fileLength/(e->isBigBlock ? sectorSize : shortSectorSize))) {
158
 		if((e->blocks=malloc(chainMaxLen*sizeof(long int))) == NULL ) {
159
 			return NULL;
160
 		}
161
@@ -308,18 +346,18 @@
162
 			}
163
 			if(chainCurrent <= 0 ||
164
 			   chainCurrent >= ( e->isBigBlock ?
165
-								 ((bbdNumBlocks*BBD_BLOCK_SIZE)/4)
166
-								 : ((sbdNumber*SBD_BLOCK_SIZE)/4) ) ||
167
+								 ((bbdNumBlocks*sectorSize)/4)
168
+								 : ((sbdNumber*shortSectorSize)/4) ) ||
169
 			   (e->numOfBlocks >
170
-				e->length/(e->isBigBlock ? sectorSize : SBD_BLOCK_SIZE))) {
171
+				e->length/(e->isBigBlock ? sectorSize : shortSectorSize))) {
172
 /*   				fprintf(stderr, "chain End=%ld\n", chainCurrent);   */
173
 				break;
174
 			}
175
 			
176
 		}
177
 	}
178
-	if(e->length > (e->isBigBlock ? sectorSize : SBD_BLOCK_SIZE)*e->numOfBlocks)
179
-		e->length = (e->isBigBlock ? sectorSize : SBD_BLOCK_SIZE)*e->numOfBlocks;
180
+	if(e->length > (e->isBigBlock ? sectorSize : shortSectorSize)*e->numOfBlocks)
181
+		e->length = (e->isBigBlock ? sectorSize : shortSectorSize)*e->numOfBlocks;
182
 /*	fprintf(stderr, "READDIR: e->name=%s e->numOfBlocks=%ld length=%ld\n",
183
 	e->name, e->numOfBlocks, e->length);*/
184
 	
185
@@ -354,13 +392,13 @@
186
 long int calcFileBlockOffset(oleEntry *e, long int blk) {
187
 	long int res;
188
 	if ( e->isBigBlock ) {
189
-		res=(e->blocks[blk]+1)*sectorSize;
190
+		res=512+e->blocks[blk]*sectorSize;
191
 	} else {
192
-		long int sbdPerSector=sectorSize/SBD_BLOCK_SIZE;
193
+		long int sbdPerSector=sectorSize/shortSectorSize;
194
 		long int sbdSecNum=e->blocks[blk]/sbdPerSector;
195
 		long int sbdSecMod=e->blocks[blk]%sbdPerSector;
196
-		res=(rootEntry->blocks[sbdSecNum]+1)*sectorSize +
197
-			sbdSecMod*SBD_BLOCK_SIZE;
198
+		res=512+rootEntry->blocks[sbdSecNum]*sectorSize +
199
+			sbdSecMod*shortSectorSize;
200
 	}
201
 	return res;
202
 }
203
@@ -386,7 +424,7 @@
204
 	if( e->readed+llen > e->length )
205
 		llen= e->length - e->readed;
206
 	
207
-	ssize = (e->isBigBlock ? sectorSize : SBD_BLOCK_SIZE);
208
+	ssize = (e->isBigBlock ? sectorSize : shortSectorSize);
209
 	blockNumber=e->readed/ssize;
210
 /* 	fprintf(stderr, "blockNumber=%ld e->numOfBlocks=%ld llen=%ld\n", */
211
 /* 			blockNumber, e->numOfBlocks, llen); */
212
Index: src/ole.h
213
===================================================================
214
RCS file: /work/oss/catdoc/src/ole.h,v
215
retrieving revision 1.3
216
diff -u -w -b -B -r1.3 ole.h
217
--- src/ole.h	14 Nov 2003 14:32:39 -0000	1.3
218
+++ src/ole.h	26 Oct 2004 09:53:48 -0000
219
@@ -17,6 +17,7 @@
220
 #define SBD_BLOCK_SIZE      64
221
 #define PROP_BLOCK_SIZE    128
222
 #define OLENAMELENGHT       32
223
+#define MSAT_ORIG_SIZE     436
224
 
225
 typedef enum {
226
 	oleDir=1,
(-)/home/hsn/hacked/catdoc/files/patch-src-Makefile.in (-11 lines)
Lines 1-11 Link Here
1
--- src/Makefile.in.orig	Sat Nov 15 18:29:14 2003
2
+++ src/Makefile.in	Sun Aug  1 02:15:09 2004
3
@@ -87,7 +87,7 @@
4
 	$(INSTALL) -m 755 wordview $(installroot)$(bindir)/wordview
5
 wordview: wordview.tcl
6
 	echo "#! $(WISH)" >wordview
7
-	echo set charset_lib "\"$(LIB_DIR)\"">>wordview
8
+	echo set charset_lib "\"$(CHARSETPATH)\"">>wordview
9
 	cat wordview.tcl >>wordview
10
 	chmod 0755 wordview
11
 strftime.o: ../compat/strftime.c
(-)/home/hsn/hacked/catdoc/pkg-plist (+7 lines)
Lines 1-4 Link Here
1
bin/catdoc
1
bin/catdoc
2
bin/catppt
2
bin/wordview
3
bin/wordview
3
bin/xls2csv
4
bin/xls2csv
4
share/catdoc/8859-1.txt
5
share/catdoc/8859-1.txt
Lines 42-47 Link Here
42
share/catdoc/cp874.txt
43
share/catdoc/cp874.txt
43
share/catdoc/koi8-r.txt
44
share/catdoc/koi8-r.txt
44
share/catdoc/koi8-u.txt
45
share/catdoc/koi8-u.txt
46
share/catdoc/mac-arabic.txt
47
share/catdoc/mac-centeuro.txt
48
share/catdoc/mac-cyrillic.txt
49
share/catdoc/mac-greek.txt
50
share/catdoc/mac-hebrew.txt
51
share/catdoc/mac-roman.txt
45
share/catdoc/tex.replchars
52
share/catdoc/tex.replchars
46
share/catdoc/tex.specchars
53
share/catdoc/tex.specchars
47
share/catdoc/us-ascii.txt
54
share/catdoc/us-ascii.txt

Return to bug 83591