diff -ur clamav-devel-jm5/clamav-milter/Makefile.in clamav-devel-jm4/clamav-milter/Makefile.in
--- clamav-devel-jm5/clamav-milter/Makefile.in	Fri Apr 23 17:07:42 2004
+++ clamav-devel-jm4/clamav-milter/Makefile.in	Fri Apr 23 17:16:38 2004
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.6.1 from Makefile.am.
+# Makefile.in generated by automake 1.6.3 from Makefile.am.
 # @configure_input@
 
 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
@@ -66,6 +66,7 @@
 INSTALL_DATA = @INSTALL_DATA@
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_HEADER = $(INSTALL_DATA)
 transform = @program_transform_name@
@@ -127,6 +128,8 @@
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/getopt.h \
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/memory.c \
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/memory.h \
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/vsnprintf_alloc.h\
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/vsnprintf_alloc.c\
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    clamav-milter.c
 
 
@@ -152,6 +155,7 @@
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	cfgparser.$(OBJEXT) \
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	getopt.$(OBJEXT) \
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	memory.$(OBJEXT) \
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	vsnprintf_alloc.$(OBJEXT) \
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	clamav-milter.$(OBJEXT)
 clamav_milter_OBJECTS = $(am_clamav_milter_OBJECTS)
 clamav_milter_LDADD = $(LDADD)
@@ -164,7 +168,8 @@
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgparser.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/clamav-milter.Po ./$(DEPDIR)/getopt.Po \
-@AMDEP_TRUE@	./$(DEPDIR)/memory.Po
+@AMDEP_TRUE@	./$(DEPDIR)/memory.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/vsnprintf_alloc.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@@ -198,8 +203,7 @@
 	  if test -f $$p \
 	     || test -f $$p1 \
 	  ; then \
-	    p1=`echo "$$p1" | sed -e 's,^.*/,,'`; \
-	    f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
 	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
 	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f; \
 	  else :; fi; \
@@ -208,17 +212,21 @@
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  f=`echo "$$f" | sed -e 's,^.*/,,'`; \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
 	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
 	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
 clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
 cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c
 getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c
 memory.$(OBJEXT): $(top_srcdir)/shared/memory.c
+vsnprintf_alloc.$(OBJEXT): $(top_srcdir)/shared/vsnprintf_alloc.c
 clamav-milter$(EXEEXT): $(clamav_milter_OBJECTS) $(clamav_milter_DEPENDENCIES) 
 	@rm -f clamav-milter$(EXEEXT)
 	$(LINK) $(clamav_milter_LDFLAGS) $(clamav_milter_OBJECTS) $(clamav_milter_LDADD) $(LIBS)
@@ -233,6 +241,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamav-milter.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsnprintf_alloc.Po@am__quote@
 
 distclean-depend:
 	-rm -rf ./$(DEPDIR)
@@ -308,6 +317,24 @@
 @AMDEP_TRUE@	depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@
 @AMDEP_TRUE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 	$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c
+
+vsnprintf_alloc.o: $(top_srcdir)/shared/vsnprintf_alloc.c
+@AMDEP_TRUE@	source='$(top_srcdir)/shared/vsnprintf_alloc.c' object='vsnprintf_alloc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@	depfile='$(DEPDIR)/vsnprintf_alloc.Po' tmpdepfile='$(DEPDIR)/vsnprintf_alloc.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vsnprintf_alloc.o `test -f '$(top_srcdir)/shared/vsnprintf_alloc.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/vsnprintf_alloc.c
+
+vsnprintf_alloc.obj: $(top_srcdir)/shared/vsnprintf_alloc.c
+@AMDEP_TRUE@	source='$(top_srcdir)/shared/vsnprintf_alloc.c' object='vsnprintf_alloc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@	depfile='$(DEPDIR)/vsnprintf_alloc.Po' tmpdepfile='$(DEPDIR)/vsnprintf_alloc.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vsnprintf_alloc.obj `cygpath -w $(top_srcdir)/shared/vsnprintf_alloc.c`
+
+vsnprintf_alloc.lo: $(top_srcdir)/shared/vsnprintf_alloc.c
+@AMDEP_TRUE@	source='$(top_srcdir)/shared/vsnprintf_alloc.c' object='vsnprintf_alloc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@	depfile='$(DEPDIR)/vsnprintf_alloc.Plo' tmpdepfile='$(DEPDIR)/vsnprintf_alloc.TPlo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+	$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vsnprintf_alloc.lo `test -f '$(top_srcdir)/shared/vsnprintf_alloc.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/vsnprintf_alloc.c
 CCDEPMODE = @CCDEPMODE@
 
 mostlyclean-libtool:
@@ -335,6 +362,10 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
 	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
@@ -400,7 +431,7 @@
 distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
+	@list='$(DISTFILES)'; for file in $$list; do \
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
 	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
@@ -446,7 +477,7 @@
 clean-generic:
 
 distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
diff -ur clamav-devel-jm5/clamav-milter/clamav-milter.c clamav-devel-jm4/clamav-milter/clamav-milter.c
--- clamav-devel-jm5/clamav-milter/clamav-milter.c	Fri Apr 23 17:07:42 2004
+++ clamav-devel-jm4/clamav-milter/clamav-milter.c	Fri Apr 23 17:16:38 2004
@@ -2083,7 +2083,7 @@
 			return cl_error;
 		}
 
-		snprintf(cmdbuf, sizeof(cmdbuf) - 1, "SCAN %s", privdata->filename);
+		snprintf(cmdbuf, sizeof(cmdbuf) - 1, "MAILSCAN %s", privdata->filename);
 
 		nbytes = (int)strlen(cmdbuf);
 
@@ -2894,7 +2894,7 @@
 
 		shutdown(privdata->dataSocket, SHUT_RD);
 
-		if(send(privdata->cmdSocket, "STREAM\n", 7, 0) < 7) {
+		if(send(privdata->cmdSocket, "MAILSTREAM\n", 11, 0) < 7) {
 			perror("send");
 			if(use_syslog)
 				syslog(LOG_ERR, "send failed to clamd");
Only in clamav-devel-jm4/clamav-milter: clamav-milter.c.orig
diff -ur clamav-devel-jm5/clamd/session.c clamav-devel-jm4/clamd/session.c
--- clamav-devel-jm5/clamd/session.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamd/session.c	Fri Apr 23 17:16:38 2004
@@ -54,6 +54,9 @@
 #define CMD9 "SESSION"
 #define CMD10 "END"
 #define CMD11 "SHUTDOWN"
+#define CMD12 "MAILSTREAM"
+#define CMD13 "MAILSCAN"
+#define CMD14 "CONTMAILSCAN"
 
 
 int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt)
@@ -150,6 +153,27 @@
     } else if(!strncmp(buff, CMD11, strlen(CMD11))) { /* SHUTDOWN */
 	return COMMAND_QUIT;
 
+    } else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* MAILSTREAM */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scanstream(desc, NULL, root, limits, options, copt);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
+    } else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* MAILSCAN */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scan(buff + strlen(CMD13) + 1, NULL, root, limits, options, copt, desc, 0);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
+    } else if(!strncmp(buff, CMD14, strlen(CMD14))) { /* CONTMAILSCAN */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scan(buff + strlen(CMD14) + 1, NULL, root, limits, options, copt, desc, 1);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
     } else {
 	mdprintf(desc, "UNKNOWN COMMAND\n");
     }
diff -ur clamav-devel-jm5/clamdscan/clamdscan.c clamav-devel-jm4/clamdscan/clamdscan.c
--- clamav-devel-jm5/clamdscan/clamdscan.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamdscan/clamdscan.c	Fri Apr 23 17:16:38 2004
@@ -126,6 +126,8 @@
     mprintf("    --verbose           -v             Be verbose\n");
     mprintf("    --quiet                            Be quiet, only output error messages\n");
     mprintf("    --stdout                           Write to stdout instead of stderr\n");
+    mprintf("    --mail, --mbox-force, -M           All unknown file type will be a RFC822 mail file\n");
+    mprintf("    --stdout                           Write to stdout instead of stderr\n");
     mprintf("                                       (this help is always written to stdout)\n");
     mprintf("    --log=FILE          -l FILE        Save scan report in FILE\n");
     mprintf("    --log-verbose                      Log additional messages\n");
diff -ur clamav-devel-jm5/clamdscan/client.c clamav-devel-jm4/clamdscan/client.c
--- clamav-devel-jm5/clamdscan/client.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamdscan/client.c	Fri Apr 23 17:16:38 2004
@@ -55,6 +55,7 @@
 	int sockd, wsockd, loopw = 60, bread, port;
 	const char *clamav_conf = getargl(opt, "config-file");
 	FILE *fd;
+	short unknown_mail = 0;
 
     if(!clamav_conf)
 	clamav_conf = DEFAULT_CFG;
@@ -64,6 +65,15 @@
 	return 2;
     }
 
+     if((cfgopt(copt, "ScanMail")) &&
+	(
+	    (optl(opt, "mbox-force")) ||
+	    (optl(opt, "mail")) ||
+	    (optc(opt, 'M'))
+         )
+        ) 
+	unknown_mail = 1;	    
+
     /* Set default address to connect to; needed for scanning a stream and no TCP address specified */
     server2.sin_addr.s_addr = inet_addr("127.0.0.1");    
     if(cfgopt(copt, "ScannerDaemonOutputFormat")) {
@@ -137,7 +147,7 @@
 	file = (char *) strdup(cwd);
 
     } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
-	if(write(sockd, "STREAM", 6) <= 0) {
+	if(write(sockd, (unknown_mail) ? "MAILSTREAM" : "STREAM", (unknown_mail) ? 10 : 6) <= 0) {
 	    mprintf("@Can't write to the socket.\n");
 	    close(sockd);
 	    return 2;
@@ -229,7 +239,7 @@
 
 
     scancmd = mcalloc(strlen(file) + 20, sizeof(char));
-    sprintf(scancmd, "CONTSCAN %s", file);
+    sprintf(scancmd, "%s %s", (unknown_mail)? "CONTMAILSCAN" : "CONTSCAN", file);
     free(file);
 
     if(write(sockd, scancmd, strlen(scancmd)) <= 0) {
diff -ur clamav-devel-jm5/clamscan/clamscan.c clamav-devel-jm4/clamscan/clamscan.c
--- clamav-devel-jm5/clamscan/clamscan.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamscan/clamscan.c	Fri Apr 23 17:16:38 2004
@@ -208,6 +208,10 @@
     mprintf("    --bell                               Sound bell on virus detection\n");
     mprintf("    --no-summary                         Disable summary at end of scanning\n");
     mprintf("    --mbox                -m             Treat stdin as a mailbox\n");
+    mprintf("    --mbox-force          -M\n");
+    mprintf("    --mail                -M             Unrecognized filetypes  will be be treated\n");
+    mprintf("                                         as RFC822 mail file.\n");
+    mprintf("                                         This implies --mbox (-m)\n");
     mprintf("\n");
     mprintf("    --no-ole2                            Disable OLE2 support\n");
     mprintf("    --no-archive                         Disable libclamav archive support\n");
diff -ur clamav-devel-jm5/clamscan/manager.c clamav-devel-jm4/clamscan/manager.c
--- clamav-devel-jm5/clamscan/manager.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamscan/manager.c	Fri Apr 23 17:16:38 2004
@@ -373,6 +373,12 @@
     if(optc(opt, 'm'))
 	options |= CL_MAIL;
 
+    if(optc(opt, 'M') || optl(opt,"mail")) {
+	options |= CL_MAIL;
+	options |= CL_UNKNOWN_MAIL;
+    }
+	
+
     /* 
      * check the extension  - this is a special case, normally we don't need to
      * do this (libclamav detects archive by its magic string), but here we
diff -ur clamav-devel-jm5/clamscan/options.c clamav-devel-jm4/clamscan/options.c
--- clamav-devel-jm5/clamscan/options.c	Fri Apr 23 17:07:43 2004
+++ clamav-devel-jm4/clamscan/options.c	Fri Apr 23 17:16:38 2004
@@ -43,7 +43,7 @@
 	int ret, opt_index, i, len;
 	struct optstruct *opt;
 
-	const char *getopt_parameters = "hvd:wriVl:m";
+	const char *getopt_parameters = "hvd:wriVl:mM";
 
 	static struct option long_options[] = {
 	    /* 
@@ -82,6 +82,8 @@
 	    {"block-encrypted", 0, 0, 0},
 	    {"no-ole2", 0, 0, 0},
 	    {"mbox", 0, 0, 'm'},
+	    {"mbox-force", 0, 0, 'M'},
+	    {"mail", 0, 0, 0},
 	    {"stdout", 0, 0, 0},
 	    {"unzip", 2, 0, 0},
 	    {"unrar", 2, 0, 0},
diff -ur clamav-devel-jm5/libclamav/clamav.h clamav-devel-jm4/libclamav/clamav.h
--- clamav-devel-jm5/libclamav/clamav.h	Fri Apr 23 17:07:46 2004
+++ clamav-devel-jm4/libclamav/clamav.h	Fri Apr 23 17:16:38 2004
@@ -69,6 +69,7 @@
 #define CL_DISABLERAR	4
 #define CL_OLE2		8
 #define CL_ENCRYPTED    16
+#define CL_UNKNOWN_MAIL	32
 
 struct cli_patt {
     short int *pattern;
diff -ur clamav-devel-jm5/libclamav/scanners.c clamav-devel-jm4/libclamav/scanners.c
--- clamav-devel-jm5/libclamav/scanners.c	Fri Apr 23 17:07:46 2004
+++ clamav-devel-jm4/libclamav/scanners.c	Fri Apr 23 17:16:38 2004
@@ -58,6 +58,7 @@
 #define SCAN_OLE2	    (options & CL_OLE2)
 #define DISABLE_RAR	    (options & CL_DISABLERAR)
 #define DETECT_ENCRYPTED    (options & CL_ENCRYPTED)
+#define SCAN_UNKNOWN_MAIL    (options & CL_UNKNOWN_MAIL)
 
 struct cli_magic_s {
     int offset;
@@ -882,6 +883,9 @@
     }
 
     type = cli_filetype(magic, bread);
+
+	if(type == CL_UNKNOWN_TYPE && SCAN_UNKNOWN_MAIL)
+		type = CL_MAILFILE;
 
     switch(type) {
 	case CL_RARFILE:
diff -ur clamav-devel-jm5/shared/cfgparser.c clamav-devel-jm4/shared/cfgparser.c
--- clamav-devel-jm5/shared/cfgparser.c	Fri Apr 23 17:07:46 2004
+++ clamav-devel-jm4/shared/cfgparser.c	Fri Apr 23 17:16:38 2004
@@ -62,6 +62,7 @@
 	    {"TemporaryDirectory", OPT_STR},
 	    {"MaxFileSize", OPT_COMPSIZE},
 	    {"ScanMail", OPT_NOARG},
+	    {"ScanUnknownAsMail", OPT_NOARG},
 	    {"ScanOLE2", OPT_NOARG},
 	    {"ScanArchive", OPT_NOARG},
 	    {"ScanRAR", OPT_NOARG},
