git-svn: trunk@1935
Nigel Horne authored on 2006/04/29 17:31:19... | ... |
@@ -35,7 +35,7 @@ |
35 | 35 |
* cli_mbox decode it |
36 | 36 |
* TODO: Remove the vcard handling |
37 | 37 |
*/ |
38 |
-static char const rcsid[] = "$Id: pst.c,v 1.13 2006/04/28 12:53:26 nigelhorne Exp $"; |
|
38 |
+static char const rcsid[] = "$Id: pst.c,v 1.14 2006/04/29 08:31:19 nigelhorne Exp $"; |
|
39 | 39 |
|
40 | 40 |
#if HAVE_CONFIG_H |
41 | 41 |
#include "clamav-config.h" /* must come first */ |
... | ... |
@@ -599,9 +599,7 @@ fileTimeToUnixTime(const FILETIME *filetime, DWORD *remainder) |
599 | 599 |
#define PST_ENC 1 |
600 | 600 |
|
601 | 601 |
// defines types of possible encryption |
602 |
-#define PST_NO_ENCRYPT 0 |
|
603 | 602 |
#define PST_COMP_ENCRYPT 1 |
604 |
-#define PST_ENCRYPT 2 |
|
605 | 603 |
|
606 | 604 |
// defines different types of mappings |
607 | 605 |
#define PST_MAP_ATTRIB 1 |
... | ... |
@@ -944,8 +942,7 @@ pst_load_extended_attributes(pst_file *pf) |
944 | 944 |
bptr += sizeof(xattrib); |
945 | 945 |
|
946 | 946 |
while (xattrib.type != 0 && bptr < bsize) { |
947 |
- ptr = (pst_x_attrib_ll*) cli_malloc(sizeof(pst_x_attrib_ll)); |
|
948 |
- memset(ptr, 0, sizeof(pst_x_attrib_ll)); |
|
947 |
+ ptr = (pst_x_attrib_ll*) cli_calloc(1, sizeof(pst_x_attrib_ll)); |
|
949 | 948 |
ptr->type = xattrib.type; |
950 | 949 |
ptr->map = xattrib.map+0x8000; |
951 | 950 |
ptr->next = NULL; |
... | ... |
@@ -958,8 +955,7 @@ pst_load_extended_attributes(pst_file *pf) |
958 | 958 |
// copy the size of the header. It is 32 bit int |
959 | 959 |
memcpy(&tint, &(headerbuffer[xattrib.extended]), sizeof(tint)); |
960 | 960 |
LE32_CPU(tint); |
961 |
- wt = (char*) cli_malloc(tint+2); // plus 2 for a uni-code zero |
|
962 |
- memset(wt, 0, tint+2); |
|
961 |
+ wt = (char*) cli_calloc(1, tint+2); // plus 2 for a uni-code zero |
|
963 | 962 |
memcpy(wt, &(headerbuffer[xattrib.extended+sizeof(tint)]), tint); |
964 | 963 |
ptr->data = _pst_wide_to_single(wt, tint); |
965 | 964 |
free(wt); |
... | ... |
@@ -970,8 +966,7 @@ pst_load_extended_attributes(pst_file *pf) |
970 | 970 |
ptr->mytype = PST_MAP_HEADER; |
971 | 971 |
} else { |
972 | 972 |
// contains the attribute code to map to. |
973 |
- ptr->data = (int*)cli_malloc(sizeof(int32_t)); |
|
974 |
- memset(ptr->data, 0, sizeof(int32_t)); |
|
973 |
+ ptr->data = (int*)cli_calloc(1, sizeof(int32_t)); |
|
975 | 974 |
*((int32_t*)ptr->data) = xattrib.extended; |
976 | 975 |
ptr->mytype = PST_MAP_ATTRIB; |
977 | 976 |
} |
... | ... |
@@ -4964,7 +4959,7 @@ pst_decode(const char *dir, int desc) |
4964 | 4964 |
// if overwrite is set to 1 we keep the existing name and don't modify anything |
4965 | 4965 |
// we don't want to go changing the file name of the SEPERATE items |
4966 | 4966 |
temp = (char*) cli_malloc (strlen(f->name)+10); //enough room for 10 digits |
4967 |
- sprintf(temp, "%s", f->name); |
|
4967 |
+ strcpy(temp, f->name); |
|
4968 | 4968 |
temp = check_filename(temp); |
4969 | 4969 |
x = 0; |
4970 | 4970 |
while ((f->output = fopen(temp, "r")) != NULL) { |
... | ... |
@@ -5045,11 +5040,10 @@ pst_decode(const char *dir, int desc) |
5045 | 5045 |
f->name = (char*) cli_malloc(strlen(item->file_as)+strlen(OUTPUT_TEMPLATE+1)); |
5046 | 5046 |
sprintf(f->name, OUTPUT_TEMPLATE, item->file_as); |
5047 | 5047 |
|
5048 |
- f->dname = (char*) cli_malloc(strlen(item->file_as)+1); |
|
5049 |
- strcpy(f->dname, item->file_as); |
|
5048 |
+ f->dname = strdup(item->file_as); |
|
5050 | 5049 |
|
5051 | 5050 |
temp = (char*) cli_malloc (strlen(f->name)+10); //enough room for 10 digits |
5052 |
- sprintf(temp, "%s", f->name); |
|
5051 |
+ strcpy(temp, f->name); |
|
5053 | 5052 |
x = 0; |
5054 | 5053 |
temp = check_filename(temp); |
5055 | 5054 |
while ((f->output = fopen(temp, "r")) != NULL) { |
... | ... |
@@ -5253,8 +5247,7 @@ pst_decode(const char *dir, int desc) |
5253 | 5253 |
b1++; |
5254 | 5254 |
} |
5255 | 5255 |
|
5256 |
- boundary = cli_malloc ((b1-b2)+1); //malloc that length |
|
5257 |
- memset (boundary, 0, (b1-b2)+1); // blank it |
|
5256 |
+ boundary = cli_calloc (1, (b1-b2)+1); //malloc that length |
|
5258 | 5257 |
strncpy(boundary, b2, b1-b2); // copy boundary to another variable |
5259 | 5258 |
b1 = b2 = boundary; |
5260 | 5259 |
while (*b2 != '\0') { // remove any CRs and Tabs |
... | ... |
@@ -5292,7 +5285,6 @@ pst_decode(const char *dir, int desc) |
5292 | 5292 |
|| item->email->encrypted_htmlbody)) { |
5293 | 5293 |
// we need to create a boundary here. |
5294 | 5294 |
boundary = cli_malloc(50 * sizeof(char)); // allow 50 chars for boundary |
5295 |
- boundary[0] = '\0'; |
|
5296 | 5295 |
sprintf(boundary, "--boundary-LibPST-iamunique-%i_-_-", rand()); |
5297 | 5296 |
} |
5298 | 5297 |
|
... | ... |
@@ -5397,10 +5389,8 @@ pst_decode(const char *dir, int desc) |
5397 | 5397 |
item->current_attach->next = item->attach; |
5398 | 5398 |
item->attach = item->current_attach; |
5399 | 5399 |
item->current_attach->data = (char *)lzfu_decompress((const unsigned char *)item->email->rtf_compressed, &nbytes); |
5400 |
- item->current_attach->filename2 = cli_malloc(strlen(RTF_ATTACH_NAME)+2); |
|
5401 |
- strcpy(item->current_attach->filename2, RTF_ATTACH_NAME); |
|
5402 |
- item->current_attach->mimetype = cli_malloc(strlen(RTF_ATTACH_TYPE)+2); |
|
5403 |
- strcpy(item->current_attach->mimetype, RTF_ATTACH_TYPE); |
|
5400 |
+ item->current_attach->filename2 = strdup(RTF_ATTACH_NAME); |
|
5401 |
+ item->current_attach->mimetype = strdup(RTF_ATTACH_TYPE); |
|
5404 | 5402 |
/*memcpy(&(item->current_attach->size), item->email->rtf_compressed+sizeof(int32_t), sizeof(int32_t)); |
5405 | 5403 |
LE32_CPU(item->current_attach->size);*/ |
5406 | 5404 |
item->current_attach->size = nbytes; |
... | ... |
@@ -5410,8 +5400,7 @@ pst_decode(const char *dir, int desc) |
5410 | 5410 |
if (item->email->encrypted_body || item->email->encrypted_htmlbody) { |
5411 | 5411 |
// if either the body or htmlbody is encrypted, add them as attachments |
5412 | 5412 |
if (item->email->encrypted_body) { |
5413 |
- item->current_attach = (pst_item_attach*) cli_malloc(sizeof(pst_item_attach)); |
|
5414 |
- memset(item->current_attach, 0, sizeof(pst_item_attach)); |
|
5413 |
+ item->current_attach = (pst_item_attach*) cli_calloc(1, sizeof(pst_item_attach)); |
|
5415 | 5414 |
item->current_attach->next = item->attach; |
5416 | 5415 |
item->attach = item->current_attach; |
5417 | 5416 |
|
... | ... |
@@ -5420,8 +5409,7 @@ pst_decode(const char *dir, int desc) |
5420 | 5420 |
item->email->encrypted_body = NULL; |
5421 | 5421 |
} |
5422 | 5422 |
if (item->email->encrypted_htmlbody) { |
5423 |
- item->current_attach = (pst_item_attach*) cli_malloc(sizeof(pst_item_attach)); |
|
5424 |
- memset(item->current_attach, 0, sizeof(pst_item_attach)); |
|
5423 |
+ item->current_attach = (pst_item_attach*) cli_calloc(1, sizeof(pst_item_attach)); |
|
5425 | 5424 |
item->current_attach->next = item->attach; |
5426 | 5425 |
item->attach = item->current_attach; |
5427 | 5426 |
|