Browse code

revert patch from bb#245

git-svn: trunk@3006

Tomasz Kojm authored on 2007/04/03 02:49:01
Showing 7 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Apr  2 18:47:30 CEST 2007 (tk)
2
+----------------------------------
3
+  * libclamav: revert patch from bb#245
4
+
1 5
 Sun Apr  1 11:12:20 CEST 2007 (tk)
2 6
 ----------------------------------
3 7
   * libclamav/others.c: remove cli_sanitise_filename()
... ...
@@ -135,7 +135,7 @@ blobSetFilename(blob *b, const char *dir, const char *filename)
135 135
 	b->name = cli_strdup(filename);
136 136
 
137 137
 	if(b->name)
138
-		cli_sanitise_filename(b->name);
138
+		sanitiseName(b->name);
139 139
 }
140 140
 
141 141
 const char *
... ...
@@ -559,3 +559,26 @@ fileblobContainsVirus(const fileblob *fb)
559 559
 {
560 560
 	return fb->isInfected ? TRUE : FALSE;
561 561
 }
562
+
563
+/*
564
+ * Different operating systems allow different characters in their filenames
565
+ * FIXME: What does QNX want? There is no #ifdef C_QNX, but if there were
566
+ * it may be best to treat it like MSDOS
567
+ */
568
+void
569
+sanitiseName(char *name)
570
+{
571
+	while(*name) {
572
+#ifdef	C_DARWIN
573
+		*name &= '\177';
574
+#endif
575
+	    /* Also check for tab - "Heinz Martin" <Martin@hemag.ch> */
576
+#if	defined(MSDOS) || defined(C_CYGWIN) || defined(C_WINDOWS) || defined(C_OS2)
577
+		if(strchr("%/*?<>|\\\"+=,;:\t ~", *name))
578
+#else
579
+		if(*name == '/')
580
+#endif
581
+			*name = '_';
582
+		name++;
583
+	}
584
+}
... ...
@@ -65,5 +65,6 @@ const	char	*fileblobGetFilename(const fileblob *fb);
65 65
 void	fileblobSetCTX(fileblob *fb, cli_ctx *ctx);
66 66
 int	fileblobAddData(fileblob *fb, const unsigned char *data, size_t len);
67 67
 int	fileblobContainsVirus(const fileblob *fb);
68
+void	sanitiseName(char *name);
68 69
 
69 70
 #endif /*_BLOB_H*/
... ...
@@ -3719,7 +3719,7 @@ rfc1341(message *m, const char *dir)
3719 3719
 			char outname[NAME_MAX + 1];
3720 3720
 			time_t now;
3721 3721
 
3722
-			cli_sanitise_filename(id);
3722
+			sanitiseName(id);
3723 3723
 
3724 3724
 			snprintf(outname, sizeof(outname) - 1, "%s/%s", dir, id);
3725 3725
 
... ...
@@ -49,6 +49,9 @@
49 49
 #include "others.h"
50 50
 #include "ole2_extract.h"
51 51
 
52
+#include "mbox.h"
53
+#include "blob.h" /* sanitiseName() */
54
+
52 55
 #define ole2_endian_convert_16(v) le16_to_host(v)
53 56
 #define ole2_endian_convert_32(v) le32_to_host(v)
54 57
 
... ...
@@ -608,7 +611,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const
608 608
 		snprintf(name, 11, "%.10ld", i + (long int) prop);
609 609
 	} else {
610 610
 		/* Sanitize the file name */
611
-		cli_sanitise_filename(name);
611
+		sanitiseName(name);
612 612
 	}
613 613
 
614 614
 	newname = (char *) cli_malloc(strlen(name) + strlen(dir) + 2);
... ...
@@ -4659,7 +4659,7 @@ check_filename(char *fname)
4659 4659
     *t = '_'; //replace them with an underscore
4660 4660
   }
4661 4661
 #endif
4662
-	cli_sanitise_filename(fname);
4662
+	sanitiseName(fname);
4663 4663
 	return fname;
4664 4664
 }
4665 4665
 
... ...
@@ -41,6 +41,8 @@ static	char	const	rcsid[] = "$Id: untar.c,v 1.35 2007/02/12 20:46:09 njh Exp $";
41 41
 #include "clamav.h"
42 42
 #include "others.h"
43 43
 #include "untar.h"
44
+#include "mbox.h"
45
+#include "blob.h"
44 46
 
45 47
 #define BLOCKSIZE 512
46 48
 
... ...
@@ -194,7 +196,7 @@ cli_untar(const char *dir, int desc, unsigned int posix, const struct cl_limits
194 194
 			 * see also fileblobSetFilename()
195 195
 			 * TODO: check if the suffix needs to be put back
196 196
 			 */
197
-			cli_sanitise_filename(name);
197
+			sanitiseName(name);
198 198
 			suffix = strrchr(name, '.');
199 199
 			if(suffix == NULL)
200 200
 				suffix = "";