Browse code

Handle ASCII85 encoded Flated objects

git-svn: trunk@2426

Nigel Horne authored on 2006/10/22 19:25:25
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Oct 22 11:24:07 BST 2006 (njh)
2
+----------------------------------
3
+  * libclamav/pdf.c:	Handle ASCII85 encoded Flated objectes (bug#43)
4
+
1 5
 Thu Oct 19 20:33:15 CEST 2006 (acab)
2 6
 ------------------------------------
3 7
   * libclamav/pe.c: remove unused variable
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: pdf.c,v 1.55 2006/09/15 18:07:34 njh Exp $";
18
+static	char	const	rcsid[] = "$Id: pdf.c,v 1.56 2006/10/22 10:23:26 njh Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -178,7 +178,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
178 178
 		char *md5digest;
179 179
 		size_t length, objlen, streamlen;
180 180
 		char fullname[NAME_MAX + 1];
181
-  
181
+
182 182
 		if(q == xrefstart)
183 183
 			break;
184 184
 		if(memcmp(q, "xref", 4) == 0)
... ...
@@ -235,6 +235,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
235 235
 		q = objstart;
236 236
 		while(q < streamstart) {
237 237
 			if(*q == '/') {	/* name object */
238
+				/*cli_dbgmsg("Name object %8.8s\n", q+1, q+1);*/
238 239
 				if(strncmp(++q, "Length ", 7) == 0) {
239 240
 					q += 7;
240 241
 					length = atoi(q);
... ...
@@ -243,8 +244,8 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
243 243
 					q--;
244 244
 				} else if(strncmp(q, "FlateDecode", 11) == 0) {
245 245
 					is_flatedecode = 1;
246
-					q += 12;
247
-				} else if(strncmp(q, "ASCII85Decode", 12) == 0) {
246
+					q += 11;
247
+				} else if(strncmp(q, "ASCII85Decode", 13) == 0) {
248 248
 					is_ascii85decode = 1;
249 249
 					q += 13;
250 250
 				}
... ...
@@ -297,7 +298,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
297 297
 			}
298 298
 		} else
299 299
 			fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600);
300
-#else	
300
+#else
301 301
 		mktemp(fullname);
302 302
 		fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600);
303 303
 #endif
... ...
@@ -308,7 +309,8 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
308 308
 			break;
309 309
 		}
310 310
 
311
-		cli_dbgmsg("length %d, streamlen %d\n", length, streamlen);
311
+		cli_dbgmsg("length %d, streamlen %d isFlate %d isASCII85 %d\n",
312
+			length, streamlen, is_flatedecode, is_ascii85decode);
312 313
 
313 314
 #if	0
314 315
 		/* FIXME: this isn't right... */
... ...
@@ -585,6 +587,7 @@ pdf_nextobject(const char *ptr, size_t len)
585 585
 
586 586
 			case ' ':
587 587
 			case '\t':
588
+			case '[':	/* Start of an array object */
588 589
 			case '\v':
589 590
 			case '\f':
590 591
 				inobject = 0;