[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

aCaB acab at clamav.net
Sun Apr 4 01:02:02 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 1c8f32c3c9a5d13dd41343b2054e4b1377000760
Merge: 8bcbfe4a1b477a3187c39eb747b59db66f8293f3 f461d74f2b2b8775d0fa8dc3ab28f29b432b8eee
Author: aCaB <acab at clamav.net>
Date:   Tue Aug 25 15:41:40 2009 +0200

    merge master

diff --combined libclamav/pdf.c
index fc93cfe,51c1e44..20306b6
--- a/libclamav/pdf.c
+++ b/libclamav/pdf.c
@@@ -26,6 -26,7 +26,6 @@@ static	char	const	rcsid[] = "$Id: pdf.c
  #include "clamav-config.h"
  #endif
  
 -#ifdef	HAVE_MMAP
  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/stat.h>
@@@ -40,6 -41,11 +40,6 @@@
  #ifdef	HAVE_UNISTD_H
  #include <unistd.h>
  #endif
 -
 -#ifdef HAVE_SYS_MMAN_H
 -#include <sys/mman.h>
 -#endif
 -
  #include <zlib.h>
  
  #ifdef	C_WINDOWS
@@@ -51,7 -57,7 +51,8 @@@
  #include "mbox.h"
  #include "pdf.h"
  #include "scanners.h"
 +#include "fmap.h"
+ #include "str.h"
  
  #ifndef	O_BINARY
  #define	O_BINARY	0
@@@ -67,7 -73,6 +68,6 @@@ static	int	flatedecode(unsigned char *b
  static	int	ascii85decode(const char *buf, off_t len, unsigned char *output);
  static	const	char	*pdf_nextlinestart(const char *ptr, size_t len);
  static	const	char	*pdf_nextobject(const char *ptr, size_t len);
- static	const	char	*cli_pmemstr(const char *haystack, size_t hs, const char *needle, size_t ns);
  
  int
  cli_pdf(const char *dir, int desc, cli_ctx *ctx, off_t offset)
@@@ -82,7 -87,7 +82,8 @@@
  	int printed_predictor_message, printed_embedded_font_message, rc;
  	unsigned int files;
  	struct stat statb;
 +	struct F_MAP *map;
+ 	int opt_failed = 0;
  
  	cli_dbgmsg("in cli_pdf(%s)\n", dir);
  
@@@ -96,13 -101,8 +97,13 @@@
  	if(size <= 7)	/* doesn't even include the file header */
  		return CL_CLEAN;
  
 -	p = buf = mmap(NULL, size, PROT_READ, MAP_PRIVATE, desc, offset);
 -	if(buf == MAP_FAILED) {
 +	if(!(map = fmap(desc, offset, size))) {
 +	    cli_errmsg("cli_pdf: mmap() failed\n");
 +	    return CL_EMAP;
 +	}
 +	
 +	p = buf = fmap_need_off(map, 0, size); /* FIXME: really port to fmap */
 +	if(!buf) {
  		cli_errmsg("cli_pdf: mmap() failed\n");
  		return CL_EMAP;
  	}
@@@ -122,7 -122,7 +123,7 @@@
  	}
  
  	if(!bytesleft) {
 -	    munmap(buf, size);
 +	    fmunmap(map);
  	    cli_dbgmsg("cli_pdf: file header not found\n");
  	    return CL_CLEAN;
  	}
@@@ -133,7 -133,7 +134,7 @@@
  			break;
  
  	if(q <= p) {
 -		munmap(buf, size);
 +		fmunmap(map);
  		cli_dbgmsg("cli_pdf: trailer not found\n");
  		return CL_CLEAN;
  	}
@@@ -146,13 -146,13 +147,13 @@@
  	 * q points to the end of the trailer section
  	 */
  	trailerlength = (long)(q - trailerstart);
- 	if(cli_pmemstr(trailerstart, trailerlength, "Encrypt", 7)) {
+ 	if(cli_memstr(trailerstart, trailerlength, "Encrypt", 7)) {
  		/*
  		 * This tends to mean that the file is, in effect, read-only
  		 * http://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt
  		 * http://www.adobe.com/devnet/pdf/
  		 */
 -		munmap(buf, size);
 +		fmunmap(map);
  		cli_dbgmsg("cli_pdf: Encrypted PDF files not yet supported\n");
  		return CL_CLEAN;
  	}
@@@ -175,7 -175,7 +176,7 @@@
  				break;
  
  	if(xrefstart == p) {
 -		munmap(buf, size);
 +		fmunmap(map);
  		cli_dbgmsg("cli_pdf: xref not found\n");
  		return CL_CLEAN;
  	}
@@@ -239,7 -239,7 +240,7 @@@
  
  		bytesleft -= (off_t)((q - p) + 3);
  		objstart = p = &q[3];
- 		objend = cli_pmemstr(p, bytesleft, "endobj", 6);
+ 		objend = cli_memstr(p, bytesleft, "endobj", 6);
  		if(objend == NULL) {
  			cli_dbgmsg("cli_pdf: No matching endobj\n");
  			break;
@@@ -249,7 -249,7 +250,7 @@@
  		objlen = (unsigned long)(objend - objstart);
  
  		/* Is this object a stream? */
- 		streamstart = cli_pmemstr(objstart, objlen, "stream", 6);
+ 		streamstart = cli_memstr(objstart, objlen, "stream", 6);
  		if(streamstart == NULL)
  			continue;
  
@@@ -275,7 -275,6 +276,6 @@@
  					 */
  					if((bytesleft > 11) && strncmp(q, " 0 R", 4) == 0) {
  						const char *r, *nq;
- 						int opt_failed = 0;
  						size_t len;
  						char b[14];
  
@@@ -287,10 -286,15 +287,15 @@@
  						length = (unsigned long)strlen(b);
  						/* optimization: assume objects
  						 * are sequential */
- 						nq = q;
- 						len = buf + size - q;
+ 						if(!opt_failed) {
+ 						    nq = q;
+ 						    len = buf + size - q;
+ 						} else {
+ 						    nq = buf;
+ 						    len = q - buf;
+ 						}
  						do {
- 							r = cli_pmemstr(nq, len, b, length);
+ 							r = cli_memstr(nq, len, b, length);
  							if (r > nq) {
  								const char x = *(r-1);
  								if (x == '\n' || x=='\r') {
@@@ -299,8 -303,8 +304,8 @@@
  								}
  							}
  							if (r) {
- 								len -= r+1-nq;
- 								nq = r + 1;
+ 								len -= r + length - nq;
+ 								nq = r + length;
  							} else if (!opt_failed) {
  								/* we failed optimized match,
  								 * try matching from the beginning
@@@ -382,9 -386,9 +387,9 @@@
  			break;
  		len -= (int)(q - streamstart);
  		streamstart = q;
- 		streamend = cli_pmemstr(streamstart, len, "endstream\n", 10);
+ 		streamend = cli_memstr(streamstart, len, "endstream\n", 10);
  		if(streamend == NULL) {
- 			streamend = cli_pmemstr(streamstart, len, "endstream\r", 10);
+ 			streamend = cli_memstr(streamstart, len, "endstream\r", 10);
  			if(streamend == NULL) {
  				cli_dbgmsg("cli_pdf: No endstream\n");
  				break;
@@@ -532,6 -536,10 +537,10 @@@
  						rc = CL_EUNLINK;
  						break;
  					}
+ 					if(cli_updatelimits(ctx, real_streamlen) != CL_SUCCESS) {
+ 						rc = CL_CLEAN;
+ 						break;
+ 					}
  					continue;
  				} else
  					tableInsert(md5table, md5str, 1);
@@@ -546,7 -554,7 +555,7 @@@
  		if(rc != CL_CLEAN) break;
  	}
  
 -	munmap(buf, size);
 +	fmunmap(map);
  
  	tableDestroy(md5table);
  
@@@ -714,7 -722,7 +723,7 @@@ ascii85decode(const char *buf, off_t le
  	int quintet = 0;
  	int ret = 0;
  
- 	if(cli_pmemstr(buf, len, "~>", 2) == NULL)
+ 	if(cli_memstr(buf, len, "~>", 2) == NULL)
  		cli_dbgmsg("cli_pdf: ascii85decode: no EOF marker found\n");
  
  	ptr = buf;
@@@ -842,43 -850,17 +851,3 @@@ pdf_nextobject(const char *ptr, size_t 
  	}
  	return NULL;
  }
--
- /*
-  * like cli_memstr - but returns the location of the match
-  * FIXME: need a case insensitive version
-  */
- static const char *
- cli_pmemstr(const char *haystack, size_t hs, const char *needle, size_t ns)
- {
- 	const char *pt, *hay;
- 	size_t n;
- 
- 	if(haystack == needle)
- 		return haystack;
- 
- 	if(hs < ns)
- 		return NULL;
- 
- 	if(memcmp(haystack, needle, ns) == 0)
- 		return haystack;
- 
- 	pt = hay = haystack;
- 	n = hs;
- 
- 	while((pt = memchr(hay, needle[0], n)) != NULL) {
- 		n -= (size_t)(pt - hay);
- 		if(n < ns)
- 			break;
- 
- 		if(memcmp(pt, needle, ns) == 0)
- 			return pt;
- 
- 		if(hay == pt) {
- 			n--;
- 			hay++;
- 		} else
- 			hay = pt;
- 	}
- 
- 	return NULL;
- }
 -#else	/*!HAVE_MMAP*/
 -
 -#include "clamav.h"
 -#include "others.h"
 -#include "pdf.h"
 -
 -int
 -cli_pdf(const char *dir, int desc, cli_ctx *ctx, off_t offset)
 -{
 -	cli_dbgmsg("File not decoded - PDF decoding needs mmap() (for now)\n");
 -	return CL_CLEAN;
 -}
 -#endif
diff --combined libclamav/scanners.c
index 4f18b3b,0d7afe5..90b8097
--- a/libclamav/scanners.c
+++ b/libclamav/scanners.c
@@@ -1062,10 -1062,10 +1062,10 @@@ static int cli_scanscript(int desc, cli
  	text_normalize_init(&state, normalized, SCANBUFF + maxpatlen);
  	ret = CL_CLEAN;
  
- 	if ((ret = cli_ac_initdata(&tmdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN)))
+ 	if ((ret = cli_ac_initdata(&tmdata, troot->ac_partsigs, troot->ac_lsigs, troot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN)))
  	    return ret;
  
- 	if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) {
+ 	if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) {
  	    cli_ac_freedata(&tmdata);
  	    return ret;
  	}
@@@ -1293,11 -1293,11 +1293,11 @@@ static int cli_scanmschm(int desc, cli_
      }
  
     do {
 -	ret = cli_chm_prepare_file(desc, dir, &metadata);
 +	ret = cli_chm_prepare_file(&metadata);
  	if (ret != CL_SUCCESS) {
  	   break;
  	}
 -	ret = cli_chm_extract_file(desc, dir, &metadata, ctx);
 +	ret = cli_chm_extract_file(dir, &metadata, ctx);
  	if (ret == CL_SUCCESS) {
  	    lseek(metadata.ofd, 0, SEEK_SET);
  	    rc = cli_magic_scandesc(metadata.ofd, ctx);

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list