Browse code

activate PDF code

git-svn: trunk@1510

Tomasz Kojm authored on 2005/05/03 09:10:46
Showing 7 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue May  3 02:09:08 CEST 2005 (tk)
2
+----------------------------------
3
+  * libclamav: activate PDF code (patch by NJH)
4
+
1 5
 Sat Apr 30 02:50:11 CEST 2005 (tk)
2 6
 ----------------------------------
3 7
   * libclamav/scanners.c: do not report I/O error with encrypted zips
... ...
@@ -136,7 +136,9 @@ libclamav_la_SOURCES = \
136 136
 	unrar/unrar20.c \
137 137
 	unrar/unrarcmd.c \
138 138
 	unrar/unrarfilter.h \
139
-	unrar/unrarppm.h
139
+	unrar/unrarppm.h \
140
+	pdf.c \
141
+	pdf.h
140 142
 
141 143
 
142 144
 lib_LTLIBRARIES = libclamav.la
... ...
@@ -87,7 +87,8 @@ am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
87 87
 	lzxd.lo mszipd.lo qtmd.lo system.lo upx.lo htmlnorm.lo \
88 88
 	chmunpack.lo rebuildpe.lo petite.lo fsg.lo line.lo untar.lo \
89 89
 	special.lo binhex.lo is_tar.lo tnef.lo unrar15.lo unrarvm.lo \
90
-	unrar.lo unrarfilter.lo unrarppm.lo unrar20.lo unrarcmd.lo
90
+	unrar.lo unrarfilter.lo unrarppm.lo unrar20.lo unrarcmd.lo \
91
+	pdf.lo
91 92
 libclamav_la_OBJECTS = $(am_libclamav_la_OBJECTS)
92 93
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
93 94
 depcomp = $(SHELL) $(top_srcdir)/depcomp
... ...
@@ -331,7 +332,9 @@ libclamav_la_SOURCES = \
331 331
 	unrar/unrar20.c \
332 332
 	unrar/unrarcmd.c \
333 333
 	unrar/unrarfilter.h \
334
-	unrar/unrarppm.h
334
+	unrar/unrarppm.h \
335
+	pdf.c \
336
+	pdf.h
335 337
 
336 338
 lib_LTLIBRARIES = libclamav.la
337 339
 all: all-am
... ...
@@ -425,6 +428,7 @@ distclean-compile:
425 425
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mszipd.Plo@am__quote@
426 426
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ole2_extract.Plo@am__quote@
427 427
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/others.Plo@am__quote@
428
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdf.Plo@am__quote@
428 429
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pe.Plo@am__quote@
429 430
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/petite.Plo@am__quote@
430 431
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmd.Plo@am__quote@
... ...
@@ -109,7 +109,7 @@ static const struct cli_magic_s cli_magic[] = {
109 109
     /* Others */
110 110
 
111 111
     {0,  "\320\317\021\340\241\261\032\341", 8, "OLE2 container", CL_TYPE_MSOLE2},
112
-    //{0,  "\%PDF-",  5, "PDF document", CL_TYPE_PDF},
112
+    {0,  "\%PDF-",			 5, "PDF document", CL_TYPE_PDF},
113 113
 
114 114
     /* Ignored types */
115 115
 
... ...
@@ -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.4 2005/05/01 11:47:49 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: pdf.c,v 1.5 2005/05/03 00:10:46 kojm Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -65,6 +65,8 @@ cli_pdf(const char *dir, int desc)
65 65
 	char *buf;
66 66
 	const char *p, *q;
67 67
 
68
+	cli_dbgmsg("in cli_pdf()\n");
69
+
68 70
 	if(fstat(desc, &statb) < 0)
69 71
 		return CL_EOPEN;
70 72
 
... ...
@@ -16,4 +16,9 @@
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18 18
 
19
+#ifndef __PDF_H
20
+#define __PDF_H
21
+
19 22
 int cli_pdf(const char *dir, int desc);
23
+
24
+#endif
... ...
@@ -1232,6 +1232,30 @@ static int cli_scanjpeg(int desc, const char **virname)
1232 1232
     return ret;
1233 1233
 }
1234 1234
 
1235
+static int cli_scanpdf(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec)
1236
+{
1237
+	int ret;
1238
+	char *dir = cli_gentemp(NULL);
1239
+
1240
+
1241
+    if(mkdir(dir, 0700)) {
1242
+	cli_dbgmsg("Can't create temporary directory for PDF file %s\n", dir);
1243
+	free(dir);
1244
+	return CL_ETMPDIR;
1245
+    }
1246
+
1247
+    ret = cli_pdf(dir, desc);
1248
+
1249
+    if(ret == CL_CLEAN)
1250
+	ret = cli_scandir(dir, virname, scanned, root, limits, options, arec, mrec);
1251
+
1252
+    if(!cli_leavetemps_flag)
1253
+	cli_rmdirs(dir);
1254
+
1255
+    free(dir);
1256
+    return ret;
1257
+}
1258
+
1235 1259
 static int cli_scantnef(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec)
1236 1260
 {
1237 1261
 	int ret;
... ...
@@ -1424,6 +1448,11 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const
1424 1424
 	    ret = cli_scanjpeg(desc, virname);
1425 1425
 	    break;
1426 1426
 
1427
+	case CL_TYPE_PDF:
1428
+	    if(SCAN_ARCHIVE)    /* you may wish to change this line */
1429
+		ret = cli_scanpdf(desc, virname, scanned, root, limits, options, arec, mrec);
1430
+	    break;
1431
+
1427 1432
 	case CL_TYPE_DATA:
1428 1433
 	    /* it could be a false positive and a standard DOS .COM file */
1429 1434
 	    {