git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@180 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/01/10 22:03:59... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.14 2004/01/10 13:01:19 nigelhorne |
|
21 |
+ * Added BinHex compression support |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.13 2004/01/09 18:01:03 nigelhorne |
21 | 24 |
* Started BinHex work |
22 | 25 |
* |
... | ... |
@@ -36,7 +39,7 @@ |
36 | 36 |
* uuencodebegin() no longer static |
37 | 37 |
* |
38 | 38 |
*/ |
39 |
-static char const rcsid[] = "$Id: message.c,v 1.13 2004/01/09 18:01:03 nigelhorne Exp $"; |
|
39 |
+static char const rcsid[] = "$Id: message.c,v 1.14 2004/01/10 13:01:19 nigelhorne Exp $"; |
|
40 | 40 |
|
41 | 41 |
#ifndef CL_DEBUG |
42 | 42 |
/*#define NDEBUG /* map CLAMAV debug onto standard */ |
... | ... |
@@ -611,7 +614,7 @@ messageToBlob(const message *m) |
611 | 611 |
blob *tmp = blobCreate(); |
612 | 612 |
unsigned char *data; |
613 | 613 |
unsigned char byte; |
614 |
- unsigned long len; |
|
614 |
+ unsigned long len, l; |
|
615 | 615 |
char *filename; |
616 | 616 |
|
617 | 617 |
/* |
... | ... |
@@ -630,7 +633,6 @@ messageToBlob(const message *m) |
630 | 630 |
|
631 | 631 |
if(data[0] == ':') { |
632 | 632 |
char *ptr; |
633 |
- unsigned long i; |
|
634 | 633 |
unsigned long newlen = 0L; |
635 | 634 |
int bytenumber = 0; |
636 | 635 |
|
... | ... |
@@ -642,8 +644,8 @@ messageToBlob(const message *m) |
642 | 642 |
ptr = cli_malloc(len); |
643 | 643 |
memcpy(ptr, data, len); |
644 | 644 |
|
645 |
- for(i = 1; i < len; i++) { |
|
646 |
- unsigned char c = ptr[i]; |
|
645 |
+ for(l = 1; l < len; l++) { |
|
646 |
+ unsigned char c = ptr[l]; |
|
647 | 647 |
char *tptr; |
648 | 648 |
|
649 | 649 |
/* TODO: table look up would be quicker */ |
... | ... |
@@ -714,8 +716,39 @@ messageToBlob(const message *m) |
714 | 714 |
* Skip over data fork length, resource fork length and CRC |
715 | 715 |
*/ |
716 | 716 |
byte += 10; |
717 |
+ data = &data[byte]; |
|
718 |
+ |
|
719 |
+ /* |
|
720 |
+ * Check for compression of repetitive characters |
|
721 |
+ */ |
|
722 |
+ if(memchr(data, 0x90, len)) |
|
723 |
+ /* |
|
724 |
+ * Includes compression |
|
725 |
+ */ |
|
726 |
+ for(l = 0; l < len; l++) { |
|
727 |
+ unsigned char c = data[l]; |
|
728 |
+ |
|
729 |
+ blobAddData(b, &c, 1); |
|
717 | 730 |
|
718 |
- blobAddData(b, &data[byte], len); |
|
731 |
+ if(l < len - 1) |
|
732 |
+ if(data[l + 1] == 0x90) { |
|
733 |
+ int count; |
|
734 |
+ |
|
735 |
+ l += 2; |
|
736 |
+ count = data[l]; |
|
737 |
+ |
|
738 |
+ if(count == 0) { |
|
739 |
+ c = 0x90; |
|
740 |
+ blobAddData(b, &c, 1); |
|
741 |
+ } else while(--l > 0) |
|
742 |
+ blobAddData(b, &c, 1); |
|
743 |
+ } |
|
744 |
+ } |
|
745 |
+ else |
|
746 |
+ /* |
|
747 |
+ * No compression - quickly copy all across |
|
748 |
+ */ |
|
749 |
+ blobAddData(b, data, len); |
|
719 | 750 |
|
720 | 751 |
blobDestroy(tmp); |
721 | 752 |
|