git-svn: trunk@2840
Nigel Horne authored on 2007/02/23 02:30:00... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Thu Feb 22 15:32:33 GMT 2007 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: s/sanitiseFilename/cli_sanitise_filename/, patch from trog |
|
4 |
+ Changed some strdup to cli_strdup |
|
5 |
+ |
|
1 | 6 |
Thu Feb 22 15:43:33 CET 2007 (acab) |
2 | 7 |
----------------------------------- |
3 | 8 |
* clamd: handle signals while polling in select mode |
... | ... |
@@ -132,10 +132,10 @@ blobSetFilename(blob *b, const char *dir, const char *filename) |
132 | 132 |
if(b->name) |
133 | 133 |
free(b->name); |
134 | 134 |
|
135 |
- b->name = strdup(filename); |
|
135 |
+ b->name = cli_strdup(filename); |
|
136 | 136 |
|
137 | 137 |
if(b->name) |
138 |
- sanitiseName(b->name); |
|
138 |
+ cli_sanitise_filename(b->name); |
|
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
const char * |
... | ... |
@@ -559,26 +559,3 @@ 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,7 +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); |
|
69 | 68 |
|
70 | 69 |
/* Maximum filenames under various systems */ |
71 | 70 |
#ifndef NAME_MAX /* e.g. Linux */ |
... | ... |
@@ -49,9 +49,6 @@ |
49 | 49 |
#include "others.h" |
50 | 50 |
#include "ole2_extract.h" |
51 | 51 |
|
52 |
-#include "mbox.h" |
|
53 |
-#include "blob.h" /* sanitiseName() */ |
|
54 |
- |
|
55 | 52 |
#define ole2_endian_convert_16(v) le16_to_host(v) |
56 | 53 |
#define ole2_endian_convert_32(v) le32_to_host(v) |
57 | 54 |
|
... | ... |
@@ -603,7 +600,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const |
603 | 603 |
snprintf(name, 11, "%.10ld", i + (long int) prop); |
604 | 604 |
} else { |
605 | 605 |
/* Sanitize the file name */ |
606 |
- sanitiseName(name); |
|
606 |
+ cli_sanitise_filename(name); |
|
607 | 607 |
} |
608 | 608 |
|
609 | 609 |
newname = (char *) cli_malloc(strlen(name) + strlen(dir) + 2); |
... | ... |
@@ -923,3 +923,31 @@ int cli_bitset_test(bitset_t *bs, unsigned long bit_offset) |
923 | 923 |
} |
924 | 924 |
return (bs->bitset[char_offset] & ((unsigned char)1 << bit_offset)); |
925 | 925 |
} |
926 |
+ |
|
927 |
+ |
|
928 |
+/* |
|
929 |
+ * Code from NJH |
|
930 |
+ * Different operating systems allow different characters in their filenames |
|
931 |
+ * FIXME: What does QNX want? There is no #ifdef C_QNX, but if there were |
|
932 |
+ * it may be best to treat it like MSDOS |
|
933 |
+ */ |
|
934 |
+void |
|
935 |
+cli_sanitise_filename(char *name) |
|
936 |
+{ |
|
937 |
+ if(name == NULL) |
|
938 |
+ return; |
|
939 |
+ |
|
940 |
+ while(*name) { |
|
941 |
+#ifdef C_DARWIN |
|
942 |
+ *name &= '\177'; |
|
943 |
+#endif |
|
944 |
+ /* Also check for tab - "Heinz Martin" <Martin@hemag.ch> */ |
|
945 |
+#if defined(MSDOS) || defined(C_CYGWIN) || defined(C_WINDOWS) || defined(C_OS2) |
|
946 |
+ if(strchr("%/*?<>|\\\"+=,;:\t ~", *name)) |
|
947 |
+#else |
|
948 |
+ if(*name == '/') |
|
949 |
+#endif |
|
950 |
+ *name = '_'; |
|
951 |
+ name++; |
|
952 |
+ } |
|
953 |
+} |
... | ... |
@@ -177,4 +177,5 @@ bitset_t *cli_bitset_init(void); |
177 | 177 |
void cli_bitset_free(bitset_t *bs); |
178 | 178 |
int cli_bitset_set(bitset_t *bs, unsigned long bit_offset); |
179 | 179 |
int cli_bitset_test(bitset_t *bs, unsigned long bit_offset); |
180 |
+void cli_sanitise_filename(char *name); |
|
180 | 181 |
#endif |
... | ... |
@@ -67,8 +67,6 @@ typedef uint32_t u_int32_t; |
67 | 67 |
|
68 | 68 |
#include "pst.h" |
69 | 69 |
|
70 |
-#include "mbox.h" |
|
71 |
- |
|
72 | 70 |
#define DWORD unsigned int |
73 | 71 |
|
74 | 72 |
#define DEBUG_VERSION 1 |
... | ... |
@@ -2116,7 +2114,7 @@ _pst_process(pst_num_array *list , pst_item *item) |
2116 | 2116 |
case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers |
2117 | 2117 |
cli_dbgmsg("Extra Field - "); |
2118 | 2118 |
ef = (pst_item_extra_field*) cli_calloc(1, sizeof(pst_item_extra_field)); |
2119 |
- ef->field_name = strdup(list->items[x]->extra); |
|
2119 |
+ ef->field_name = cli_strdup(list->items[x]->extra); |
|
2120 | 2120 |
LIST_COPY(ef->value, (char*)); |
2121 | 2121 |
ef->next = item->extra_fields; |
2122 | 2122 |
item->extra_fields = ef; |
... | ... |
@@ -4662,7 +4660,7 @@ check_filename(char *fname) |
4662 | 4662 |
*t = '_'; //replace them with an underscore |
4663 | 4663 |
} |
4664 | 4664 |
#endif |
4665 |
- sanitiseName(fname); |
|
4665 |
+ cli_sanitise_filename(fname); |
|
4666 | 4666 |
return fname; |
4667 | 4667 |
} |
4668 | 4668 |
|
... | ... |
@@ -4990,7 +4988,7 @@ pst_decode(const char *dir, int desc) |
4990 | 4990 |
* exist |
4991 | 4991 |
*/ |
4992 | 4992 |
if (item->file_as == NULL) { |
4993 |
- item->file_as = strdup("clamav-pst"); |
|
4993 |
+ item->file_as = cli_strdup("clamav-pst"); |
|
4994 | 4994 |
if(item->file_as == NULL) { |
4995 | 4995 |
pst_close(&pstfile); |
4996 | 4996 |
return CL_EMEM; |
... | ... |
@@ -5013,7 +5011,7 @@ pst_decode(const char *dir, int desc) |
5013 | 5013 |
} |
5014 | 5014 |
sprintf(f->name, OUTPUT_TEMPLATE, item->file_as); |
5015 | 5015 |
|
5016 |
- f->dname = strdup(item->file_as); |
|
5016 |
+ f->dname = cli_strdup(item->file_as); |
|
5017 | 5017 |
|
5018 | 5018 |
// if overwrite is set to 1 we keep the existing name and don't modify anything |
5019 | 5019 |
// we don't want to go changing the file name of the SEPERATE items |
... | ... |
@@ -5101,7 +5099,7 @@ pst_decode(const char *dir, int desc) |
5101 | 5101 |
f->name = (char*) cli_malloc(strlen(item->file_as)+strlen(OUTPUT_TEMPLATE+1)); |
5102 | 5102 |
sprintf(f->name, OUTPUT_TEMPLATE, item->file_as); |
5103 | 5103 |
|
5104 |
- f->dname = strdup(item->file_as); |
|
5104 |
+ f->dname = cli_strdup(item->file_as); |
|
5105 | 5105 |
|
5106 | 5106 |
temp = (char*) cli_malloc (strlen(f->name)+10); //enough room for 10 digits |
5107 | 5107 |
strcpy(temp, f->name); |
... | ... |
@@ -5456,8 +5454,8 @@ pst_decode(const char *dir, int desc) |
5456 | 5456 |
item->current_attach->next = item->attach; |
5457 | 5457 |
item->attach = item->current_attach; |
5458 | 5458 |
item->current_attach->data = (char *)lzfu_decompress((const unsigned char *)item->email->rtf_compressed, &nbytes); |
5459 |
- item->current_attach->filename2 = strdup(RTF_ATTACH_NAME); |
|
5460 |
- item->current_attach->mimetype = strdup(RTF_ATTACH_TYPE); |
|
5459 |
+ item->current_attach->filename2 = cli_strdup(RTF_ATTACH_NAME); |
|
5460 |
+ item->current_attach->mimetype = cli_strdup(RTF_ATTACH_TYPE); |
|
5461 | 5461 |
/*memcpy(&(item->current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); |
5462 | 5462 |
LE32_CPU(item->current_attach->size);*/ |
5463 | 5463 |
item->current_attach->size = nbytes; |
... | ... |
@@ -94,7 +94,7 @@ tableInsert(table_t *table, const char *key, int value) |
94 | 94 |
for(tableItem = table->tableHead; tableItem; tableItem = tableItem->next) |
95 | 95 |
if(tableItem->key == NULL) { |
96 | 96 |
/* This item has been deleted */ |
97 |
- tableItem->key = strdup(key); |
|
97 |
+ tableItem->key = cli_strdup(key); |
|
98 | 98 |
tableItem->value = value; |
99 | 99 |
return value; |
100 | 100 |
} |
... | ... |
@@ -110,7 +110,7 @@ tableInsert(table_t *table, const char *key, int value) |
110 | 110 |
return -1; |
111 | 111 |
|
112 | 112 |
table->tableLast->next = NULL; |
113 |
- table->tableLast->key = strdup(key); |
|
113 |
+ table->tableLast->key = cli_strdup(key); |
|
114 | 114 |
table->tableLast->value = value; |
115 | 115 |
|
116 | 116 |
return value; |
... | ... |
@@ -41,8 +41,6 @@ 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" |
|
46 | 44 |
|
47 | 45 |
#define BLOCKSIZE 512 |
48 | 46 |
|
... | ... |
@@ -200,7 +198,7 @@ cli_untar(const char *dir, int desc, unsigned int posix, const struct cl_limits |
200 | 200 |
* see also fileblobSetFilename() |
201 | 201 |
* TODO: check if the suffix needs to be put back |
202 | 202 |
*/ |
203 |
- sanitiseName(name); |
|
203 |
+ cli_sanitise_filename(name); |
|
204 | 204 |
suffix = strrchr(name, '.'); |
205 | 205 |
if(suffix == NULL) |
206 | 206 |
suffix = ""; |