Browse code

Remove more valgrind errors

git-svn: trunk@1945

Nigel Horne authored on 2006/05/03 00:20:12
Showing 1 changed files
... ...
@@ -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.16 2006/05/01 17:36:05 nigelhorne Exp $";
38
+static	char	const	rcsid[] = "$Id: pst.c,v 1.17 2006/05/02 15:20:12 nigelhorne Exp $";
39 39
 
40 40
 #if HAVE_CONFIG_H
41 41
 #include "clamav-config.h"	/* must come first */
... ...
@@ -327,9 +327,9 @@ typedef struct _pst_item {
327 327
   struct _pst_item_folder *folder; /* data reffering to folder */
328 328
   struct _pst_item_contact *contact; /* data reffering to contact */
329 329
   struct _pst_item_attach *attach; /* linked list of attachments */
330
-  struct _pst_item_attach *current_attach; // pointer to current attachment
331
-  struct _pst_item_message_store * message_store; // data referring to the message store
332
-  struct _pst_item_extra_field *extra_fields; // linked list of extra headers and such
330
+  struct _pst_item_attach *current_attach; /* pointer to current attachment */
331
+  struct _pst_item_message_store * message_store; /* data referring to the message store */
332
+  struct _pst_item_extra_field *extra_fields; /* linked list of extra headers and such */
333 333
   struct _pst_item_journal *journal; // data reffering to a journal entry
334 334
   struct _pst_item_appointment *appointment; // data reffering to a calendar entry
335 335
   int32_t type;
... ...
@@ -432,7 +432,7 @@ static int32_t _pst_getAtPos(FILE* fp, int32_t pos, void *buf, u_int32_t size);
432 432
 int32_t _pst_get (FILE *fp, void *buf, u_int32_t size);
433 433
 size_t	_pst_ff_getIDblock_dec(pst_file *pf, u_int32_t id, unsigned char **b);
434 434
 static	size_t _pst_ff_getIDblock(pst_file *pf, u_int32_t id, unsigned char** b);
435
-size_t _pst_ff_getID2block(pst_file *pf, u_int32_t id2, pst_index2_ll *id2_head, unsigned char** buf);
435
+static	size_t	_pst_ff_getID2block(pst_file *pf, u_int32_t id2, pst_index2_ll *id2_head, unsigned char** buf);
436 436
 static	size_t _pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, struct holder *h);
437 437
 static	size_t _pst_ff_compile_ID(pst_file *pf, u_int32_t id, struct holder *h, int32_t size);
438 438
 
... ...
@@ -801,13 +801,20 @@ static int32_t
801 801
 pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE *fp)
802 802
 {
803 803
 	pst_index_ll *ptr;
804
-	struct holder h = {NULL, fp, 1, "", 0};
805 804
 	int32_t size;
806 805
 	char *c;
807 806
 
808 807
 	if (attach->id_val != -1) {
809 808
 		ptr = _pst_getID(pf, attach->id_val);
809
+
810 810
     if (ptr != NULL) {
811
+	struct holder h;
812
+
813
+	memset(&h, '\0', sizeof(struct holder));
814
+
815
+	h.fp = fp;
816
+	h.base64 = 1;
817
+
811 818
       size = _pst_ff_getID2data(pf, ptr, &h);
812 819
       // will need to encode any bytes left over
813 820
       c = base64_encode((const unsigned char *)h.base64_extra_chars, h.base64_extra);
... ...
@@ -3805,7 +3812,7 @@ _pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr) {
3805 3805
     //an error occured in block read
3806 3806
     cli_warnmsg("block read error occured. offset = %#x, size = %#x\n", list->offset, list->size);
3807 3807
     if(buf)
3808
-    	free(buf);
3808
+	free(buf);
3809 3809
     return NULL;
3810 3810
   }
3811 3811
 
... ...
@@ -3816,7 +3823,7 @@ _pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr) {
3816 3816
   if (block_head.type != 0x0002) { // some sort of constant?
3817 3817
     cli_warnmsg("Unknown constant [%#x] at start of id2 values [offset %#x].\n", block_head.type, list->offset);
3818 3818
     if(buf)
3819
-    	free(buf);
3819
+	free(buf);
3820 3820
     return NULL;
3821 3821
   }
3822 3822
 
... ...
@@ -4345,16 +4352,23 @@ _pst_ff_getIDblock(pst_file *pf, u_int32_t id, unsigned char** b)
4345 4345
 }
4346 4346
 
4347 4347
 #define PST_PTR_BLOCK_SIZE 0x120
4348
-size_t _pst_ff_getID2block(pst_file *pf, u_int32_t id2, pst_index2_ll *id2_head, unsigned char** buf) {
4349
-  pst_index_ll* ptr;
4350
-  struct holder h = {buf, NULL, 0, {'\0', '\0', '\0'}, 0};
4351
-  ptr = _pst_getID2(id2_head, id2);
4348
+static size_t
4349
+_pst_ff_getID2block(pst_file *pf, u_int32_t id2, pst_index2_ll *id2_head, unsigned char** buf)
4350
+{
4351
+	pst_index_ll* ptr;
4352
+	struct holder h;
4352 4353
 
4353
-  if (ptr == NULL) {
4354
-    cli_dbgmsg("Cannot find id2 value %#x\n", id2);
4355
-    return 0;
4356
-  }
4357
-  return _pst_ff_getID2data(pf, ptr, &h);
4354
+	ptr = _pst_getID2(id2_head, id2);
4355
+
4356
+	if (ptr == NULL) {
4357
+		cli_dbgmsg("Cannot find id2 value %#x\n", id2);
4358
+		return 0;
4359
+	}
4360
+
4361
+	memset(&h, '\0', sizeof(struct holder));
4362
+	h.buf = buf;
4363
+
4364
+	return _pst_ff_getID2data(pf, ptr, &h);
4358 4365
 }
4359 4366
 
4360 4367
 static size_t
... ...
@@ -4624,46 +4638,48 @@ static const char *
4624 4624
 rfc2426_escape(const char *str)
4625 4625
 {
4626 4626
 	static char* buf = NULL;
4627
-	const char *ret, *a;
4627
+	const char *a;
4628 4628
 	char *b;
4629
-	int x = 0, y, z;
4629
+	int x, y, z;
4630 4630
 
4631
-  if (str == NULL)
4632
-    ret = str;
4633
-  else {
4631
+	if(str == NULL)
4632
+		return NULL;
4634 4633
 
4635
-    // calculate space required to escape all the following characters
4636
-    x = strlen(str) +(y=(chr_count(str, ',')*2) + (chr_count(str, '\\')*2) + (chr_count(str, ';')*2) + (chr_count(str, '\n')*2));
4637
-    z = chr_count(str, '\r');
4638
-    if (y == 0 && z == 0)
4639
-      // there isn't any extra space required
4640
-      ret = str;
4641
-    else {
4642
-      buf = (char*) cli_realloc(buf, x+1);
4643
-      a = str;
4644
-      b = buf;
4645
-      while (*a != '\0') {
4646
-	switch(*a) {
4647
-	case ',' :
4648
-	case '\\':
4649
-	case ';' :
4650
-	case '\n':
4651
-	  *(b++)='\\';
4652
-	  *b=*a;
4653
-	break;
4654
-	case '\r':
4655
-	  break;
4656
-	default:
4657
-	  *b=*a;
4634
+	/* calculate space required to escape all the following characters */
4635
+	x = strlen(str) +(y=(chr_count(str, ',')*2) + (chr_count(str, '\\')*2) + (chr_count(str, ';')*2) + (chr_count(str, '\n')*2));
4636
+	z = chr_count(str, '\r');
4637
+
4638
+	if (y == 0 && z == 0) /* there isn't any extra space required */
4639
+		return str;
4640
+
4641
+	buf = (char *)cli_realloc(buf, x + 1 - z);
4642
+	a = str;
4643
+	b = buf;
4644
+
4645
+	while(*a != '\0') {
4646
+		switch(*a) {
4647
+			case '\n':
4648
+				*b++ = '\\';
4649
+				*b = 'n';
4650
+				break;
4651
+			case ',' :
4652
+			case '\\':
4653
+			case ';' :
4654
+				*b++ = '\\';
4655
+				*b = *a;
4656
+				break;
4657
+			case '\r':
4658
+				b--;
4659
+				break;
4660
+			default:
4661
+				*b = *a;
4662
+		}
4663
+		b++;
4664
+		a++;
4658 4665
 	}
4659
-	b++;
4660
-      a++;
4661
-      }
4662
-      *b = '\0';
4663
-      ret = buf;
4664
-    }
4665
-  }
4666
-  return ret;
4666
+	*b = '\0';
4667
+
4668
+	return buf;
4667 4669
 }
4668 4670
 
4669 4671
 /* my_stristr varies from strstr in that its searches are case-insensitive */
... ...
@@ -4729,8 +4745,16 @@ write_email_body(FILE *f, const char *body)
4729 4729
 			putc('>', f);
4730 4730
 
4731 4731
 		if((n = strchr(body, '\n')) != NULL) {
4732
+			size_t ret;
4733
+
4732 4734
 			n++;
4733
-			(void)fwrite(body, n-body, 1, f);	/* write just a line */
4735
+			/* write just a line */
4736
+			ret = fwrite(body, 1, (size_t)(n - body), f);
4737
+			if(ret != (size_t)(n - body)) {
4738
+				cli_errmsg("write_email_body: only wrote %u of $u bytes\n",
4739
+					ret, n - body);
4740
+				return ret;
4741
+			}
4734 4742
 
4735 4743
 			body = n;
4736 4744
 		}
... ...
@@ -4957,7 +4981,7 @@ pst_decode(const char *dir, int desc)
4957 4957
       x++;
4958 4958
       sprintf(temp, "%s%08d", f->name, x);
4959 4959
       if (x == 99999999) {
4960
-	cli_errmsg("main: Why can I not create a folder %s? I have tried %i extensions...\n", f->name, x);
4960
+	cli_errmsg("pst_decode: Why can I not create a folder %s? I have tried %i extensions...\n", f->name, x);
4961 4961
       }
4962 4962
       fclose(f->output);
4963 4963
     }
... ...
@@ -4972,7 +4996,7 @@ pst_decode(const char *dir, int desc)
4972 4972
     sprintf(filename, "%s/%s", dir, f->name);
4973 4973
 	cli_dbgmsg("PST: create %s\n", filename);
4974 4974
     if ((f->output = fopen(filename, "w")) == NULL) {
4975
-      cli_errmsg("main: Could not open file \"%s\" for write\n", filename);
4975
+      cli_errmsg("pst_decode: Could not open file \"%s\" for write\n", filename);
4976 4976
     free(filename);
4977 4977
 	return CL_ETMPFILE;
4978 4978
     }
... ...
@@ -4989,7 +5013,7 @@ pst_decode(const char *dir, int desc)
4989 4989
   }
4990 4990
 
4991 4991
   /*  if ((item = _pst_parse_item(&pstfile, d_ptr)) == NULL || item->folder == NULL) {
4992
-    printf("main: Could not get \"Top Of Personal Folder\" record\n");
4992
+    printf("pst_decode: Could not get \"Top Of Personal Folder\" record\n");
4993 4993
     return -2;
4994 4994
     }*/
4995 4995
   d_ptr = d_ptr->child; // do the children of TOPF
... ...
@@ -5010,7 +5034,7 @@ pst_decode(const char *dir, int desc)
5010 5010
     if (item != NULL) {
5011 5011
       if (item->message_store != NULL) {
5012 5012
 	// there should only be one message_store, and we have already done it
5013
-	cli_errmsg("main: A second message_store has been found. Sorry, this must be an error.\n");
5013
+	cli_errmsg("pst_decode: A second message_store has been found. Sorry, this must be an error.\n");
5014 5014
       }
5015 5015
 
5016 5016
 
... ...
@@ -5041,7 +5065,7 @@ pst_decode(const char *dir, int desc)
5041 5041
 	    x++;
5042 5042
 	    sprintf(temp, "%s%08d", f->name, x);
5043 5043
 	    if (x == 99999999) {
5044
-	      cli_errmsg("main: Why can I not create a folder %s? I have tried %i extensions...\n", f->name, x);
5044
+	      cli_errmsg("pst_decode: Why can I not create a folder %s? I have tried %i extensions...\n", f->name, x);
5045 5045
 	      return(5);
5046 5046
 	    }
5047 5047
 	    fclose(f->output);
... ...
@@ -5057,7 +5081,7 @@ pst_decode(const char *dir, int desc)
5057 5057
 	  sprintf(filename, "%s/%s", dir, f->name);
5058 5058
 	cli_dbgmsg("PST: create %s\n", filename);
5059 5059
 	  if ((f->output = fopen(filename, "w")) == NULL) {
5060
-	    cli_errmsg("main: Could not open file \"%s\" for write\n", f->name);
5060
+	    cli_errmsg("pst_decode: Could not open file \"%s\" for write\n", f->name);
5061 5061
 	    free(filename);
5062 5062
 	    return CL_ETMPFILE;
5063 5063
 	  }
... ...
@@ -5087,11 +5111,11 @@ pst_decode(const char *dir, int desc)
5087 5087
 	f->email_count++;
5088 5088
 
5089 5089
 	if (item->contact == NULL) { // this is an incorrect situation. Inform user
5090
-	  cli_errmsg("main: ERROR. This contact has not been fully parsed. one of the pre-requisties is NULL\n");
5090
+	  cli_errmsg("pst_decode: ERROR. This contact has not been fully parsed. one of the pre-requisties is NULL\n");
5091 5091
 	} else {
5092 5092
 	  if (contact_mode == CMODE_VCARD) {
5093 5093
 	    // the specification I am following is (hopefully) RFC2426 vCard Mime Directory Profile
5094
-	    fprintf(f->output, "BEGIN:VCARD\n");
5094
+	    fputs("BEGIN:VCARD\n", f->output);
5095 5095
 	    fprintf(f->output, "FN:%s\n", rfc2426_escape(item->contact->fullname));
5096 5096
 	    fprintf(f->output, "N:%s;%s;%s;%s;%s\n",
5097 5097
 		    rfc2426_escape((item->contact->surname==NULL?"":item->contact->surname)),
... ...
@@ -5177,20 +5201,20 @@ pst_decode(const char *dir, int desc)
5177 5177
 	    if (item->contact->profession != NULL)
5178 5178
 	      fprintf(f->output, "ROLE:%s\n", rfc2426_escape(item->contact->profession));
5179 5179
 	    if (item->contact->assistant_name != NULL || item->contact->assistant_phone != NULL) {
5180
-	      fprintf(f->output, "AGENT:BEGIN:VCARD\\n");
5180
+	      fputs("AGENT:BEGIN:VCARD\n", f->output);
5181 5181
 	      if (item->contact->assistant_name != NULL)
5182
-		fprintf(f->output, "FN:%s\\n", rfc2426_escape(item->contact->assistant_name));
5182
+		fprintf(f->output, "FN:%s\n", rfc2426_escape(item->contact->assistant_name));
5183 5183
 	      if (item->contact->assistant_phone != NULL)
5184
-		fprintf(f->output, "TEL:%s\\n", rfc2426_escape(item->contact->assistant_phone));
5185
-	      fprintf(f->output, "END:VCARD\\n\n");
5184
+		fprintf(f->output, "TEL:%s\n", rfc2426_escape(item->contact->assistant_phone));
5185
+		fputs("END:VCARD\n\n", f->output);
5186 5186
 	    }
5187 5187
 	    if (item->contact->company_name != NULL)
5188 5188
 	      fprintf(f->output, "ORG:%s\n", rfc2426_escape(item->contact->company_name));
5189 5189
 	    if (item->comment != NULL)
5190 5190
 	      fprintf(f->output, "NOTE:%s\n", rfc2426_escape(item->comment));
5191 5191
 
5192
-	    fprintf(f->output, "VERSION: 3.0\n");
5193
-	    fprintf(f->output, "END:VCARD\n\n");
5192
+	    fputs("VERSION: 3.0\n", f->output);
5193
+	    fputs("END:VCARD\n\n", f->output);
5194 5194
 	  } else {
5195 5195
 	    fprintf(f->output, "%s <%s>\n", item->contact->fullname, item->contact->address1);
5196 5196
 	  }
... ...
@@ -5250,9 +5274,8 @@ pst_decode(const char *dir, int desc)
5250 5250
 	    }
5251 5251
 	    *b1 = '\0';
5252 5252
 
5253
-	  } else {
5254
-	    cli_errmsg("main: boundary not found in header\n");
5255
-	  }
5253
+	  } else
5254
+		cli_errmsg("pst_decode: boundary not found in header\n");
5256 5255
 
5257 5256
 	  // also possible to set 7bit encoding detection here.
5258 5257
 	  if ((b2 = my_stristr(item->email->header, "Content-Transfer-Encoding:")) != NULL) {
... ...
@@ -5265,9 +5288,8 @@ pst_decode(const char *dir, int desc)
5265 5265
 		cli_dbgmsg("body is base64 encoded\n");
5266 5266
 		base64_body = 1;
5267 5267
 	      }
5268
-	    } else {
5268
+	    } else
5269 5269
 	      cli_errmsg("found a ':' during the my_stristr, but not after that..\n");
5270
-	    }
5271 5270
 	  }
5272 5271
 
5273 5272
 	}
... ...
@@ -5312,9 +5334,8 @@ pst_decode(const char *dir, int desc)
5312 5312
 	  fprintf(f->output, "From: \"%s\" <%s>\n", item->email->outlook_sender_name, temp);
5313 5313
 	  if (item->email->subject != NULL) {
5314 5314
 	    fprintf(f->output, "Subject: %s\n", item->email->subject->subj);
5315
-	  } else {
5316
-	    fprintf(f->output, "Subject: \n");
5317
-	  }
5315
+	  } /*else
5316
+	    fprintf(f->output, "Subject: \n");*/
5318 5317
 	  fprintf(f->output, "To: %s\n", item->email->sentto_address);
5319 5318
 	  if (item->email->cc_address != NULL) {
5320 5319
 	    fprintf(f->output, "CC: %s\n", item->email->cc_address);
... ...
@@ -5326,7 +5347,7 @@ pst_decode(const char *dir, int desc)
5326 5326
 	    free(c_time);
5327 5327
 	  }
5328 5328
 
5329
-	  fprintf(f->output, "MIME-Version: 1.0\n");
5329
+	  fputs("MIME-Version: 1.0\n", f->output);
5330 5330
 	  if (item->attach != NULL) {
5331 5331
 	    // write the boundary stuff if we have attachments
5332 5332
 	    fprintf(f->output, "Content-type: multipart/mixed;\n\tboundary=\"%s\"\n",
... ...
@@ -5336,18 +5357,18 @@ pst_decode(const char *dir, int desc)
5336 5336
 	    fprintf(f->output, "Content-type: multipart/alternate;\n\tboundary=\"%s\"\n",
5337 5337
 		    boundary);
5338 5338
 	  } else if (item->email->htmlbody) {
5339
-	    fprintf(f->output, "Content-type: text/html\n");
5339
+	    fputs("Content-type: text/html\n", f->output);
5340 5340
 	  }
5341
-	  fprintf(f->output, "\n");
5341
+	  putc('\n', f->output);
5342 5342
 	}
5343 5343
 
5344 5344
 
5345 5345
 	if (item->email->body != NULL) {
5346 5346
 	  if (boundary) {
5347 5347
 	    fprintf(f->output, "\n--%s\n", boundary);
5348
-	    fprintf(f->output, "Content-type: text/plain\n\n");
5348
+	    fputs("Content-type: text/plain\n\n", f->output);
5349 5349
 	    if (base64_body)
5350
-	      fprintf(f->output, "Content-Transfer-Encoding: base64\n");
5350
+	      fputs("Content-Transfer-Encoding: base64\n", f->output);
5351 5351
 	  }
5352 5352
 	  removeCR(item->email->body);
5353 5353
 	  if (base64_body)
... ...
@@ -5360,9 +5381,9 @@ pst_decode(const char *dir, int desc)
5360 5360
 	if (item->email->htmlbody != NULL) {
5361 5361
 	  if (boundary) {
5362 5362
 	    fprintf(f->output, "\n--%s\n", boundary);
5363
-	    fprintf(f->output, "Content-type: text/html\n\n");
5363
+	    fputs("Content-type: text/html\n\n", f->output);
5364 5364
 	    if (base64_body)
5365
-	      fprintf(f->output, "Content-Transfer-Encoding: base64\n");
5365
+	      fputs("Content-Transfer-Encoding: base64\n", f->output);
5366 5366
 	  }
5367 5367
 	  removeCR(item->email->htmlbody);
5368 5368
 	  if (base64_body)
... ...
@@ -5415,11 +5436,11 @@ pst_decode(const char *dir, int desc)
5415 5415
 	item->current_attach = item->attach;
5416 5416
 	while (item->current_attach != NULL) {
5417 5417
 	  if (item->current_attach->data == NULL) {
5418
-	    cli_dbgmsg("main: Data of attachment is NULL!. Size is supposed to be %i\n", item->current_attach->size);
5418
+	    cli_dbgmsg("pst_decode: Data of attachment is NULL!. Size is supposed to be %i\n", item->current_attach->size);
5419 5419
 	  }
5420 5420
 	    if (item->current_attach->data != NULL) {
5421 5421
 	      if ((enc = base64_encode ((const unsigned char *)item->current_attach->data, item->current_attach->size)) == NULL) {
5422
-		cli_errmsg("main: ERROR base64_encode returned NULL. Must have failed\n");
5422
+		cli_errmsg("pst_decode: ERROR base64_encode returned NULL. Must have failed\n");
5423 5423
 		item->current_attach = item->current_attach->next;
5424 5424
 		continue;
5425 5425
 	      }
... ...
@@ -5431,56 +5452,55 @@ pst_decode(const char *dir, int desc)
5431 5431
 	      } else {
5432 5432
 		fprintf(f->output, "Content-type: %s\n", item->current_attach->mimetype);
5433 5433
 	      }
5434
-	      fprintf(f->output, "Content-transfer-encoding: base64\n");
5435
-	      if (item->current_attach->filename2 == NULL) {
5436
-		fprintf(f->output, "Content-Disposition: inline\n\n");
5437
-	      } else {
5434
+	      fputs("Content-transfer-encoding: base64\n", f->output);
5435
+	      if (item->current_attach->filename2 == NULL)
5436
+		fputs("Content-Disposition: inline\n\n", f->output);
5437
+	      else
5438 5438
 		fprintf(f->output, "Content-Disposition: attachment; filename=\"%s\"\n\n",
5439 5439
 			item->current_attach->filename2);
5440
-	      }
5441 5440
 	    }
5442 5441
 	    if (item->current_attach->data != NULL) {
5443 5442
 		fputs(enc, f->output);
5444 5443
 		free(enc);
5445 5444
 	    } else
5446 5445
 	      pst_attach_to_file_base64(&pstfile, item->current_attach, f->output);
5447
-	    fprintf(f->output, "\n\n");
5446
+	    fputs("\n\n", f->output);
5448 5447
 	  item->current_attach = item->current_attach->next;
5449 5448
 	  attach_num++;
5450 5449
 	}
5451 5450
 	  if (boundary)
5452 5451
 	    fprintf(f->output, "\n--%s--\n", boundary);
5453
-	  fprintf(f->output, "\n\n");
5452
+	    fputs("\n\n", f->output);
5454 5453
 	// }}}2
5455 5454
       } else if (item->type == PST_TYPE_JOURNAL) {
5456 5455
 	// Process Journal item {{{2
5457 5456
 	// deal with journal items
5458 5457
 	f->email_count++;
5459 5458
 
5460
-	cli_dbgmsg("main: Processing Journal Entry\n");
5459
+	cli_dbgmsg("pst_decode: Processing Journal Entry\n");
5461 5460
 	if (f->type != PST_TYPE_JOURNAL) {
5462
-	  cli_dbgmsg("main: I have a journal entry, but folder isn't specified as a journal type. Processing...\n");
5461
+	  cli_dbgmsg("pst_decode: I have a journal entry, but folder isn't specified as a journal type. Processing...\n");
5463 5462
 	}
5464 5463
 
5465 5464
 	/*	if (item->type != PST_TYPE_JOURNAL) {
5466
-	  printf("main: I have an item with journal info, but it's type is \"%s\" \n. Processing...\n",
5465
+	  printf("pst_decode: I have an item with journal info, but it's type is \"%s\" \n. Processing...\n",
5467 5466
 		      item->ascii_type));
5468 5467
 	}*/
5469
-	fprintf(f->output, "BEGIN:VJOURNAL\n");
5468
+	fputs("BEGIN:VJOURNAL\n", f->output);
5470 5469
 	if (item->email->subject != NULL)
5471 5470
 	  fprintf(f->output, "SUMMARY:%s\n", rfc2426_escape(item->email->subject->subj));
5472 5471
 	if (item->email->body != NULL)
5473 5472
 	  fprintf(f->output, "DESCRIPTION:%s\n", rfc2426_escape(item->email->body));
5474 5473
 	if (item->journal->start != NULL)
5475 5474
 	  fprintf(f->output, "DTSTART;VALUE=DATE-TIME:%s\n", rfc2445_datetime_format(item->journal->start));
5476
-	fprintf(f->output, "END:VJOURNAL\n\n");
5475
+	fputs("END:VJOURNAL\n\n", f->output);
5477 5476
 	// }}}2
5478 5477
       } else if (item->type == PST_TYPE_APPOINTMENT) {
5479 5478
 	// Process Calendar Appointment item {{{2
5480 5479
 	// deal with Calendar appointments
5481 5480
 	f->email_count++;
5482 5481
 
5483
-	fprintf(f->output, "BEGIN:VEVENT\n");
5482
+	fputs("BEGIN:VEVENT\n", f->output);
5484 5483
 	if (item->create_date != NULL)
5485 5484
 	  fprintf(f->output, "CREATED:%s\n", rfc2445_datetime_format(item->create_date));
5486 5485
 	if (item->modify_date != NULL)
... ...
@@ -5498,14 +5518,14 @@ pst_decode(const char *dir, int desc)
5498 5498
 	if (item->appointment != NULL) {
5499 5499
 	  switch (item->appointment->showas) {
5500 5500
 	  case PST_FREEBUSY_TENTATIVE:
5501
-	    fprintf(f->output, "STATUS:TENTATIVE\n");
5501
+	    fputs("STATUS:TENTATIVE\n", f->output);
5502 5502
 	    break;
5503 5503
 	  case PST_FREEBUSY_FREE:
5504 5504
 	    // mark as transparent and as confirmed
5505
-	    fprintf(f->output, "TRANSP:TRANSPARENT\n");
5505
+	    fputs("TRANSP:TRANSPARENT\n", f->output);
5506 5506
 	  case PST_FREEBUSY_BUSY:
5507 5507
 	  case PST_FREEBUSY_OUT_OF_OFFICE:
5508
-	    fprintf(f->output, "STATUS:CONFIRMED\n");
5508
+	    fputs("STATUS:CONFIRMED\n", f->output);
5509 5509
 	    break;
5510 5510
 	  }
5511 5511
 	  switch (item->appointment->label) {
... ...
@@ -5533,16 +5553,16 @@ pst_decode(const char *dir, int desc)
5533 5533
 	    fprintf(f->output, "CATEGORIES:PHONE-CALL\n"); break;
5534 5534
 	  }
5535 5535
 	}
5536
-	fprintf(f->output, "END:VEVENT\n\n");
5536
+	fputs("END:VEVENT\n\n", f->output);
5537 5537
 	// }}}2
5538 5538
       } else {
5539 5539
 	f->skip_count++;
5540
-	cli_errmsg("main: Unknown item type. %i. Ascii1=\"%s\"\n",
5540
+	cli_errmsg("pst_decode: Unknown item type. %i. Ascii1=\"%s\"\n",
5541 5541
 		   item->type, item->ascii_type);
5542 5542
       }
5543 5543
     } else {
5544 5544
       f->skip_count++;
5545
-      cli_errmsg("main: A NULL item was seen\n");
5545
+      cli_errmsg("pst_decode: A NULL item was seen\n");
5546 5546
     }
5547 5547
 
5548 5548
     if (boundary) {