git-svn: trunk@1926
Nigel Horne authored on 2006/04/25 17:11:22... | ... |
@@ -1,5 +1,9 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2006 Nigel Horne <njh@bandsman.co.uk> |
|
2 |
+ * Based on libpst version 0.5.1, written by Dave Smith, dave.s at earthcorp.com |
|
3 |
+ * http://alioth.debian.org/projects/libpst/ |
|
4 |
+ * For copyright information on that code, refer to libpst |
|
5 |
+ * |
|
6 |
+ * Portions Copyright (C) 2006 Nigel Horne <njh@bandsman.co.uk> |
|
3 | 7 |
* |
4 | 8 |
* This program is free software; you can redistribute it and/or modify |
5 | 9 |
* it under the terms of the GNU General Public License as published by |
... | ... |
@@ -16,13 +20,11 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
* |
19 |
- * Based on libpst version 0.5.1, written by Dave Smith, dave.s at earthcorp.com |
|
20 |
- * http://alioth.debian.org/projects/libpst/ |
|
21 |
- * |
|
22 | 19 |
* Notice that this code has yet to be sanitised, and audited. Use at your |
23 | 20 |
* peril |
21 |
+ * FIXME: lots of memory leaks on error returns |
|
24 | 22 |
*/ |
25 |
-static char const rcsid[] = "$Id: pst.c,v 1.4 2006/04/24 21:19:02 nigelhorne Exp $"; |
|
23 |
+static char const rcsid[] = "$Id: pst.c,v 1.5 2006/04/25 08:11:22 nigelhorne Exp $"; |
|
26 | 24 |
|
27 | 25 |
#include <unistd.h> |
28 | 26 |
#include <stdio.h> |
... | ... |
@@ -86,15 +88,6 @@ typedef struct { |
86 | 86 |
unsigned int dwHighDateTime; |
87 | 87 |
} FILETIME; |
88 | 88 |
|
89 |
-typedef struct _pst_misc_6_struct { |
|
90 |
- int32_t i1; |
|
91 |
- int32_t i2; |
|
92 |
- int32_t i3; |
|
93 |
- int32_t i4; |
|
94 |
- int32_t i5; |
|
95 |
- int32_t i6; |
|
96 |
-} pst_misc_6; |
|
97 |
- |
|
98 | 89 |
typedef struct _pst_entryid_struct { |
99 | 90 |
int32_t u1; |
100 | 91 |
char entryid[16]; |
... | ... |
@@ -486,9 +479,9 @@ static char *base64_encode(void *data, size_t size); |
486 | 486 |
int |
487 | 487 |
cli_pst(const char *dir, int desc) |
488 | 488 |
{ |
489 |
- /*cli_warnmsg("PST files not yet supported\n"); |
|
490 |
- return CL_EFORMAT;*/ |
|
491 |
- return pst_decode(dir, desc); |
|
489 |
+ cli_warnmsg("PST files not yet supported\n"); |
|
490 |
+ return CL_EFORMAT; |
|
491 |
+ /*return pst_decode(dir, desc);*/ |
|
492 | 492 |
} |
493 | 493 |
|
494 | 494 |
static const char * |
... | ... |
@@ -519,86 +512,84 @@ fileTimeToStructTM(const FILETIME *filetime) |
519 | 519 |
static time_t |
520 | 520 |
fileTimeToUnixTime(const FILETIME *filetime, DWORD *remainder) |
521 | 521 |
{ |
522 |
- /* Read the comment in the function DOSFS_UnixTimeToFileTime. */ |
|
523 | 522 |
#if USE_LONG_LONG |
524 |
- |
|
525 |
- long long int t = filetime->dwHighDateTime; |
|
526 |
- t <<= 32; |
|
527 |
- t += (uint32_t)filetime->dwLowDateTime; |
|
528 |
- t -= 116444736000000000LL; |
|
529 |
- if (t < 0) { |
|
530 |
- if (remainder) *remainder = 9999999 - (-t - 1) % 10000000; |
|
531 |
- return -1 - ((-t - 1) / 10000000); |
|
532 |
- } else { |
|
533 |
- if (remainder) *remainder = t % 10000000; |
|
534 |
- return t / 10000000; |
|
535 |
- } |
|
536 |
- |
|
523 |
+ long long int t = filetime->dwHighDateTime; |
|
524 |
+ t <<= 32; |
|
525 |
+ t += (uint32_t)filetime->dwLowDateTime; |
|
526 |
+ t -= 116444736000000000LL; |
|
527 |
+ if (t < 0) { |
|
528 |
+ if (remainder) |
|
529 |
+ *remainder = 9999999 - (-t - 1) % 10000000; |
|
530 |
+ return -1 - ((-t - 1) / 10000000); |
|
531 |
+ } else { |
|
532 |
+ if (remainder) |
|
533 |
+ *remainder = t % 10000000; |
|
534 |
+ return t / 10000000; |
|
535 |
+ } |
|
537 | 536 |
#else /* ISO version */ |
538 |
- |
|
539 |
- uint32_t a0; /* 16 bit, low bits */ |
|
540 |
- uint32_t a1; /* 16 bit, medium bits */ |
|
541 |
- uint32_t a2; /* 32 bit, high bits */ |
|
542 |
- uint32_t r; /* remainder of division */ |
|
543 |
- unsigned int carry; /* carry bit for subtraction */ |
|
544 |
- int negative; /* whether a represents a negative value */ |
|
545 |
- |
|
546 |
- /* Copy the time values to a2/a1/a0 */ |
|
547 |
- a2 = (uint32_t)filetime->dwHighDateTime; |
|
548 |
- a1 = ((uint32_t)filetime->dwLowDateTime ) >> 16; |
|
549 |
- a0 = ((uint32_t)filetime->dwLowDateTime ) & 0xffff; |
|
550 |
- |
|
551 |
- /* Subtract the time difference */ |
|
552 |
- if (a0 >= 32768 ) a0 -= 32768 , carry = 0; |
|
553 |
- else a0 += (1 << 16) - 32768 , carry = 1; |
|
554 |
- |
|
555 |
- if (a1 >= 54590 + carry) a1 -= 54590 + carry, carry = 0; |
|
556 |
- else a1 += (1 << 16) - 54590 - carry, carry = 1; |
|
557 |
- |
|
558 |
- a2 -= 27111902 + carry; |
|
559 |
- |
|
560 |
- /* If a is negative, replace a by (-1-a) */ |
|
561 |
- negative = (a2 >= ((uint32_t)1) << 31); |
|
562 |
- if (negative) |
|
563 |
- { |
|
537 |
+ uint32_t a0; /* 16 bit, low bits */ |
|
538 |
+ uint32_t a1; /* 16 bit, medium bits */ |
|
539 |
+ uint32_t a2; /* 32 bit, high bits */ |
|
540 |
+ uint32_t r; /* remainder of division */ |
|
541 |
+ unsigned int carry; /* carry bit for subtraction */ |
|
542 |
+ int negative; /* whether a represents a negative value */ |
|
543 |
+ |
|
544 |
+ /* Copy the time values to a2/a1/a0 */ |
|
545 |
+ a2 = (uint32_t)filetime->dwHighDateTime; |
|
546 |
+ a1 = ((uint32_t)filetime->dwLowDateTime ) >> 16; |
|
547 |
+ a0 = ((uint32_t)filetime->dwLowDateTime ) & 0xffff; |
|
548 |
+ |
|
549 |
+ /* Subtract the time difference */ |
|
550 |
+ if (a0 >= 32768 ) a0 -= 32768 , carry = 0; |
|
551 |
+ else a0 += (1 << 16) - 32768 , carry = 1; |
|
552 |
+ |
|
553 |
+ if (a1 >= 54590 + carry) a1 -= 54590 + carry, carry = 0; |
|
554 |
+ else a1 += (1 << 16) - 54590 - carry, carry = 1; |
|
555 |
+ |
|
556 |
+ a2 -= 27111902 + carry; |
|
557 |
+ |
|
558 |
+ /* If a is negative, replace a by (-1-a) */ |
|
559 |
+ negative = (a2 >= ((uint32_t)1) << 31); |
|
560 |
+ if (negative) |
|
561 |
+ { |
|
564 | 562 |
/* Set a to -a - 1 (a is a2/a1/a0) */ |
565 | 563 |
a0 = 0xffff - a0; |
566 | 564 |
a1 = 0xffff - a1; |
567 | 565 |
a2 = ~a2; |
568 |
- } |
|
566 |
+ } |
|
569 | 567 |
|
570 |
- /* Divide a by 10000000 (a = a2/a1/a0), put the rest into r. |
|
571 |
- Split the divisor into 10000 * 1000 which are both less than 0xffff. */ |
|
572 |
- a1 += (a2 % 10000) << 16; |
|
573 |
- a2 /= 10000; |
|
574 |
- a0 += (a1 % 10000) << 16; |
|
575 |
- a1 /= 10000; |
|
576 |
- r = a0 % 10000; |
|
577 |
- a0 /= 10000; |
|
578 |
- |
|
579 |
- a1 += (a2 % 1000) << 16; |
|
580 |
- a2 /= 1000; |
|
581 |
- a0 += (a1 % 1000) << 16; |
|
582 |
- a1 /= 1000; |
|
583 |
- r += (a0 % 1000) * 10000; |
|
584 |
- a0 /= 1000; |
|
585 |
- |
|
586 |
- /* If a was negative, replace a by (-1-a) and r by (9999999 - r) */ |
|
587 |
- if (negative) |
|
588 |
- { |
|
568 |
+ /* Divide a by 10000000 (a = a2/a1/a0), put the rest into r. |
|
569 |
+ Split the divisor into 10000 * 1000 which are both less than 0xffff. */ |
|
570 |
+ a1 += (a2 % 10000) << 16; |
|
571 |
+ a2 /= 10000; |
|
572 |
+ a0 += (a1 % 10000) << 16; |
|
573 |
+ a1 /= 10000; |
|
574 |
+ r = a0 % 10000; |
|
575 |
+ a0 /= 10000; |
|
576 |
+ |
|
577 |
+ a1 += (a2 % 1000) << 16; |
|
578 |
+ a2 /= 1000; |
|
579 |
+ a0 += (a1 % 1000) << 16; |
|
580 |
+ a1 /= 1000; |
|
581 |
+ r += (a0 % 1000) * 10000; |
|
582 |
+ a0 /= 1000; |
|
583 |
+ |
|
584 |
+ /* If a was negative, replace a by (-1-a) and r by (9999999 - r) */ |
|
585 |
+ if (negative) |
|
586 |
+ { |
|
589 | 587 |
/* Set a to -a - 1 (a is a2/a1/a0) */ |
590 | 588 |
a0 = 0xffff - a0; |
591 | 589 |
a1 = 0xffff - a1; |
592 | 590 |
a2 = ~a2; |
593 | 591 |
|
594 |
- r = 9999999 - r; |
|
595 |
- } |
|
592 |
+ r = 9999999 - r; |
|
593 |
+ } |
|
596 | 594 |
|
597 |
- if (remainder) *remainder = r; |
|
595 |
+ if (remainder) *remainder = r; |
|
598 | 596 |
|
599 |
- /* Do not replace this by << 32, it gives a compiler warning and it does |
|
600 |
- not work. */ |
|
601 |
- return ((((time_t)a2) << 16) << 16) + (a1 << 16) + a0; |
|
597 |
+ /* Do not replace this by << 32, it gives a compiler warning and it does |
|
598 |
+ not work. */ |
|
599 |
+ return ((((time_t)a2) << 16) << 16) + (a1 << 16) + a0; |
|
602 | 600 |
#endif |
603 | 601 |
} |
604 | 602 |
|
... | ... |
@@ -685,39 +676,40 @@ typedef struct _pst_id2_assoc { |
685 | 685 |
// of the encrypted value. ie the encrypted value 0x13 represents 0x02 |
686 | 686 |
// 0 1 2 3 4 5 6 7 |
687 | 687 |
// 8 9 a b c d e f |
688 |
-static const unsigned char comp_enc [] = |
|
689 |
- { 0x47, 0xf1, 0xb4, 0xe6, 0x0b, 0x6a, 0x72, 0x48, |
|
690 |
- 0x85, 0x4e, 0x9e, 0xeb, 0xe2, 0xf8, 0x94, 0x53, /*0x0f*/ |
|
691 |
- 0xe0, 0xbb, 0xa0, 0x02, 0xe8, 0x5a, 0x09, 0xab, |
|
692 |
- 0xdb, 0xe3, 0xba, 0xc6, 0x7c, 0xc3, 0x10, 0xdd, /*0x1f*/ |
|
693 |
- 0x39, 0x05, 0x96, 0x30, 0xf5, 0x37, 0x60, 0x82, |
|
694 |
- 0x8c, 0xc9, 0x13, 0x4a, 0x6b, 0x1d, 0xf3, 0xfb, /*0x2f*/ |
|
695 |
- 0x8f, 0x26, 0x97, 0xca, 0x91, 0x17, 0x01, 0xc4, |
|
696 |
- 0x32, 0x2d, 0x6e, 0x31, 0x95, 0xff, 0xd9, 0x23, /*0x3f*/ |
|
697 |
- 0xd1, 0x00, 0x5e, 0x79, 0xdc, 0x44, 0x3b, 0x1a, |
|
698 |
- 0x28, 0xc5, 0x61, 0x57, 0x20, 0x90, 0x3d, 0x83, /*0x4f*/ |
|
699 |
- 0xb9, 0x43, 0xbe, 0x67, 0xd2, 0x46, 0x42, 0x76, |
|
700 |
- 0xc0, 0x6d, 0x5b, 0x7e, 0xb2, 0x0f, 0x16, 0x29, /*0x5f*/ |
|
701 |
- 0x3c, 0xa9, 0x03, 0x54, 0x0d, 0xda, 0x5d, 0xdf, |
|
702 |
- 0xf6, 0xb7, 0xc7, 0x62, 0xcd, 0x8d, 0x06, 0xd3, /*0x6f*/ |
|
703 |
- 0x69, 0x5c, 0x86, 0xd6, 0x14, 0xf7, 0xa5, 0x66, |
|
704 |
- 0x75, 0xac, 0xb1, 0xe9, 0x45, 0x21, 0x70, 0x0c, /*0x7f*/ |
|
705 |
- 0x87, 0x9f, 0x74, 0xa4, 0x22, 0x4c, 0x6f, 0xbf, |
|
706 |
- 0x1f, 0x56, 0xaa, 0x2e, 0xb3, 0x78, 0x33, 0x50, /*0x8f*/ |
|
707 |
- 0xb0, 0xa3, 0x92, 0xbc, 0xcf, 0x19, 0x1c, 0xa7, |
|
708 |
- 0x63, 0xcb, 0x1e, 0x4d, 0x3e, 0x4b, 0x1b, 0x9b, /*0x9f*/ |
|
709 |
- 0x4f, 0xe7, 0xf0, 0xee, 0xad, 0x3a, 0xb5, 0x59, |
|
710 |
- 0x04, 0xea, 0x40, 0x55, 0x25, 0x51, 0xe5, 0x7a, /*0xaf*/ |
|
711 |
- 0x89, 0x38, 0x68, 0x52, 0x7b, 0xfc, 0x27, 0xae, |
|
712 |
- 0xd7, 0xbd, 0xfa, 0x07, 0xf4, 0xcc, 0x8e, 0x5f, /*0xbf*/ |
|
713 |
- 0xef, 0x35, 0x9c, 0x84, 0x2b, 0x15, 0xd5, 0x77, |
|
714 |
- 0x34, 0x49, 0xb6, 0x12, 0x0a, 0x7f, 0x71, 0x88, /*0xcf*/ |
|
715 |
- 0xfd, 0x9d, 0x18, 0x41, 0x7d, 0x93, 0xd8, 0x58, |
|
716 |
- 0x2c, 0xce, 0xfe, 0x24, 0xaf, 0xde, 0xb8, 0x36, /*0xdf*/ |
|
717 |
- 0xc8, 0xa1, 0x80, 0xa6, 0x99, 0x98, 0xa8, 0x2f, |
|
718 |
- 0x0e, 0x81, 0x65, 0x73, 0xe4, 0xc2, 0xa2, 0x8a, /*0xef*/ |
|
719 |
- 0xd4, 0xe1, 0x11, 0xd0, 0x08, 0x8b, 0x2a, 0xf2, |
|
720 |
- 0xed, 0x9a, 0x64, 0x3f, 0xc1, 0x6c, 0xf9, 0xec}; /*0xff*/ |
|
688 |
+static const unsigned char comp_enc [] = { |
|
689 |
+ 0x47, 0xf1, 0xb4, 0xe6, 0x0b, 0x6a, 0x72, 0x48, |
|
690 |
+ 0x85, 0x4e, 0x9e, 0xeb, 0xe2, 0xf8, 0x94, 0x53, /*0x0f*/ |
|
691 |
+ 0xe0, 0xbb, 0xa0, 0x02, 0xe8, 0x5a, 0x09, 0xab, |
|
692 |
+ 0xdb, 0xe3, 0xba, 0xc6, 0x7c, 0xc3, 0x10, 0xdd, /*0x1f*/ |
|
693 |
+ 0x39, 0x05, 0x96, 0x30, 0xf5, 0x37, 0x60, 0x82, |
|
694 |
+ 0x8c, 0xc9, 0x13, 0x4a, 0x6b, 0x1d, 0xf3, 0xfb, /*0x2f*/ |
|
695 |
+ 0x8f, 0x26, 0x97, 0xca, 0x91, 0x17, 0x01, 0xc4, |
|
696 |
+ 0x32, 0x2d, 0x6e, 0x31, 0x95, 0xff, 0xd9, 0x23, /*0x3f*/ |
|
697 |
+ 0xd1, 0x00, 0x5e, 0x79, 0xdc, 0x44, 0x3b, 0x1a, |
|
698 |
+ 0x28, 0xc5, 0x61, 0x57, 0x20, 0x90, 0x3d, 0x83, /*0x4f*/ |
|
699 |
+ 0xb9, 0x43, 0xbe, 0x67, 0xd2, 0x46, 0x42, 0x76, |
|
700 |
+ 0xc0, 0x6d, 0x5b, 0x7e, 0xb2, 0x0f, 0x16, 0x29, /*0x5f*/ |
|
701 |
+ 0x3c, 0xa9, 0x03, 0x54, 0x0d, 0xda, 0x5d, 0xdf, |
|
702 |
+ 0xf6, 0xb7, 0xc7, 0x62, 0xcd, 0x8d, 0x06, 0xd3, /*0x6f*/ |
|
703 |
+ 0x69, 0x5c, 0x86, 0xd6, 0x14, 0xf7, 0xa5, 0x66, |
|
704 |
+ 0x75, 0xac, 0xb1, 0xe9, 0x45, 0x21, 0x70, 0x0c, /*0x7f*/ |
|
705 |
+ 0x87, 0x9f, 0x74, 0xa4, 0x22, 0x4c, 0x6f, 0xbf, |
|
706 |
+ 0x1f, 0x56, 0xaa, 0x2e, 0xb3, 0x78, 0x33, 0x50, /*0x8f*/ |
|
707 |
+ 0xb0, 0xa3, 0x92, 0xbc, 0xcf, 0x19, 0x1c, 0xa7, |
|
708 |
+ 0x63, 0xcb, 0x1e, 0x4d, 0x3e, 0x4b, 0x1b, 0x9b, /*0x9f*/ |
|
709 |
+ 0x4f, 0xe7, 0xf0, 0xee, 0xad, 0x3a, 0xb5, 0x59, |
|
710 |
+ 0x04, 0xea, 0x40, 0x55, 0x25, 0x51, 0xe5, 0x7a, /*0xaf*/ |
|
711 |
+ 0x89, 0x38, 0x68, 0x52, 0x7b, 0xfc, 0x27, 0xae, |
|
712 |
+ 0xd7, 0xbd, 0xfa, 0x07, 0xf4, 0xcc, 0x8e, 0x5f, /*0xbf*/ |
|
713 |
+ 0xef, 0x35, 0x9c, 0x84, 0x2b, 0x15, 0xd5, 0x77, |
|
714 |
+ 0x34, 0x49, 0xb6, 0x12, 0x0a, 0x7f, 0x71, 0x88, /*0xcf*/ |
|
715 |
+ 0xfd, 0x9d, 0x18, 0x41, 0x7d, 0x93, 0xd8, 0x58, |
|
716 |
+ 0x2c, 0xce, 0xfe, 0x24, 0xaf, 0xde, 0xb8, 0x36, /*0xdf*/ |
|
717 |
+ 0xc8, 0xa1, 0x80, 0xa6, 0x99, 0x98, 0xa8, 0x2f, |
|
718 |
+ 0x0e, 0x81, 0x65, 0x73, 0xe4, 0xc2, 0xa2, 0x8a, /*0xef*/ |
|
719 |
+ 0xd4, 0xe1, 0x11, 0xd0, 0x08, 0x8b, 0x2a, 0xf2, |
|
720 |
+ 0xed, 0x9a, 0x64, 0x3f, 0xc1, 0x6c, 0xf9, 0xec |
|
721 |
+}; /*0xff*/ |
|
721 | 722 |
|
722 | 723 |
static int32_t |
723 | 724 |
pst_open(pst_file *pf, int desc, const char *mode) |
... | ... |
@@ -726,7 +718,7 @@ pst_open(pst_file *pf, int desc, const char *mode) |
726 | 726 |
u_int32_t sig; |
727 | 727 |
// unsigned char ind_type; |
728 | 728 |
|
729 |
-#ifdef _MSC_VER |
|
729 |
+#ifdef _O_BINARY |
|
730 | 730 |
// set the default open mode for windows |
731 | 731 |
_fmode = _O_BINARY; |
732 | 732 |
#endif //_MSC_VER |
... | ... |
@@ -5416,30 +5408,47 @@ pst_decode(const char *dir, int desc) |
5416 | 5416 |
struct file_ll *f, *head; |
5417 | 5417 |
char *enc; // base64 encoded attachment |
5418 | 5418 |
|
5419 |
- if(pst_open(&pstfile, desc, "r") != 0) |
|
5420 |
- return(1); |
|
5421 |
- if(pst_load_index(&pstfile) != 0) |
|
5422 |
- return(2); |
|
5419 |
+ if(pst_open(&pstfile, desc, "r") != 0) |
|
5420 |
+ return CL_EOPEN; |
|
5421 |
+ |
|
5422 |
+ if(pst_load_index(&pstfile) != 0) |
|
5423 |
+ return CL_EFORMAT; |
|
5424 |
+ |
|
5423 | 5425 |
pst_load_extended_attributes(&pstfile); |
5424 | 5426 |
|
5425 | 5427 |
d_ptr = pstfile.d_head; // first record is main record |
5426 |
- if ((item = _pst_parse_item(&pstfile, d_ptr)) == NULL || item->message_store == NULL) { |
|
5427 |
- pst_close(&pstfile); |
|
5428 |
- return(3); |
|
5429 |
- } |
|
5428 |
+ if ((item = _pst_parse_item(&pstfile, d_ptr)) == NULL || item->message_store == NULL) { |
|
5429 |
+ pst_close(&pstfile); |
|
5430 |
+ return CL_EFORMAT; |
|
5431 |
+ } |
|
5430 | 5432 |
|
5431 |
- // default the file_as to the same as the main filename if it doesn't exist |
|
5432 |
- if (item->file_as == NULL) { |
|
5433 |
- item->file_as = strdup("clamav-pst"); |
|
5434 |
- } |
|
5435 |
- f = (struct file_ll*) cli_malloc(sizeof(struct file_ll)); |
|
5436 |
- memset(f, 0, sizeof(struct file_ll)); |
|
5437 |
- f->email_count = 0; |
|
5438 |
- f->skip_count = 0; |
|
5439 |
- f->next = NULL; |
|
5440 |
- head = f; |
|
5441 |
- f->name = (char*) cli_malloc(strlen(item->file_as)+strlen(OUTPUT_TEMPLATE)+1); |
|
5442 |
- sprintf(f->name, OUTPUT_TEMPLATE, item->file_as); |
|
5433 |
+ /* |
|
5434 |
+ * default the file_as to the same as the main filename if it doesn't |
|
5435 |
+ * exist |
|
5436 |
+ */ |
|
5437 |
+ if (item->file_as == NULL) { |
|
5438 |
+ item->file_as = strdup("clamav-pst"); |
|
5439 |
+ if(item->file_as == NULL) { |
|
5440 |
+ pst_close(&pstfile); |
|
5441 |
+ return CL_EMEM; |
|
5442 |
+ } |
|
5443 |
+ } |
|
5444 |
+ head = f = (struct file_ll*)cli_calloc(1, sizeof(struct file_ll)); |
|
5445 |
+ |
|
5446 |
+ if(f == NULL) { |
|
5447 |
+ free(item->file_as); |
|
5448 |
+ pst_close(&pstfile); |
|
5449 |
+ return CL_EMEM; |
|
5450 |
+ } |
|
5451 |
+ |
|
5452 |
+ f->name = (char*) cli_malloc(strlen(item->file_as)+strlen(OUTPUT_TEMPLATE)+1); |
|
5453 |
+ if(f->name == NULL) { |
|
5454 |
+ free(f); |
|
5455 |
+ free(item->file_as); |
|
5456 |
+ pst_close(&pstfile); |
|
5457 |
+ return CL_EMEM; |
|
5458 |
+ } |
|
5459 |
+ sprintf(f->name, OUTPUT_TEMPLATE, item->file_as); |
|
5443 | 5460 |
|
5444 | 5461 |
f->dname = (char*) cli_malloc(strlen(item->file_as)+1); |
5445 | 5462 |
strcpy(f->dname, item->file_as); |
... | ... |
@@ -5467,10 +5476,11 @@ pst_decode(const char *dir, int desc) |
5467 | 5467 |
f->name = check_filename(f->name); |
5468 | 5468 |
filename = cli_malloc(strlen(f->name) + strlen(dir) + 2); |
5469 | 5469 |
sprintf(filename, "%s/%s", dir, f->name); |
5470 |
+ cli_dbgmsg("PST: create %s\n", filename); |
|
5470 | 5471 |
if ((f->output = fopen(filename, "w")) == NULL) { |
5471 | 5472 |
cli_errmsg("main: Could not open file \"%s\" for write\n", filename); |
5472 | 5473 |
free(filename); |
5473 |
- return 1; |
|
5474 |
+ return CL_ETMPFILE; |
|
5474 | 5475 |
} |
5475 | 5476 |
free(filename); |
5476 | 5477 |
f->type = item->type; |
... | ... |
@@ -5554,10 +5564,11 @@ pst_decode(const char *dir, int desc) |
5554 | 5554 |
|
5555 | 5555 |
filename = cli_malloc(strlen(dir) + strlen(f->name) + 2); |
5556 | 5556 |
sprintf(filename, "%s/%s", dir, f->name); |
5557 |
+ cli_dbgmsg("PST: create %s\n", filename); |
|
5557 | 5558 |
if ((f->output = fopen(filename, "w")) == NULL) { |
5558 | 5559 |
cli_errmsg("main: Could not open file \"%s\" for write\n", f->name); |
5559 | 5560 |
free(filename); |
5560 |
- return(6); |
|
5561 |
+ return CL_ETMPFILE; |
|
5561 | 5562 |
} |
5562 | 5563 |
free(filename); |
5563 | 5564 |
if (d_ptr->child != NULL) { |