Browse code

blobGetData now allows contents to be changed - tuttut

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@188 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/01/14 19:09:59
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Jan 14 10:09:30 GMT 2004 (njh)
2
+----------------------------------
3
+  * libclamav: blobGetData now allows contents to be changed - tuttut
4
+
1 5
 Wed Jan 14 04:44:03 CET 2004 (tk)
2 6
 ---------------------------------
3 7
   * libclamav: reversed zziplib patch from 20031224 (due to a problem reported
... ...
@@ -14,7 +14,10 @@
14 14
  *  You should have received a copy of the GNU General Public License
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ *
18
+ * $LOG$
17 19
  */
20
+static	char	const	rcsid[] = "$Id: blob.c,v 1.3 2004/01/14 10:08:59 nigelhorne Exp $";
18 21
 
19 22
 #include <stdlib.h>
20 23
 #include <string.h>
... ...
@@ -146,7 +149,7 @@ blobAddData(blob *b, const unsigned char *data, size_t len)
146 146
 #else
147 147
 		b->size += 128 * 1024;
148 148
 #endif
149
-		b->data = realloc(b->data, b->size);
149
+		b->data = cli_realloc(b->data, b->size);
150 150
 	}
151 151
 
152 152
 	assert(b->data != NULL);
... ...
@@ -155,7 +158,7 @@ blobAddData(blob *b, const unsigned char *data, size_t len)
155 155
 	b->len += len;
156 156
 }
157 157
 
158
-const unsigned char *
158
+unsigned char *
159 159
 blobGetData(const blob *b)
160 160
 {
161 161
 	assert(b != NULL);
... ...
@@ -14,6 +14,8 @@
14 14
  *  You should have received a copy of the GNU General Public License
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ *
18
+ * $LOG$
17 19
  */
18 20
 
19 21
 typedef struct blob {
... ...
@@ -32,5 +34,5 @@ void	blobArrayDestroy(blob *b[], int n);
32 32
 void	blobSetFilename(blob *b, const char *filename);
33 33
 const	char	*blobGetFilename(const blob *b);
34 34
 void	blobAddData(blob *b, const unsigned char *data, size_t len);
35
-const	unsigned char *blobGetData(const blob *b);
35
+unsigned char *blobGetData(const blob *b);
36 36
 unsigned	long	blobGetDataSize(const blob *b);
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.15  2004/01/14 10:08:45  nigelhorne
21
+ * blobGetData now allows contents to be changed - tuttut
22
+ *
20 23
  * Revision 1.14  2004/01/10 13:01:19  nigelhorne
21 24
  * Added BinHex compression support
22 25
  *
... ...
@@ -39,7 +42,7 @@
39 39
  * uuencodebegin() no longer static
40 40
  *
41 41
  */
42
-static	char	const	rcsid[] = "$Id: message.c,v 1.14 2004/01/10 13:01:19 nigelhorne Exp $";
42
+static	char	const	rcsid[] = "$Id: message.c,v 1.15 2004/01/14 10:08:45 nigelhorne Exp $";
43 43
 
44 44
 #ifndef	CL_DEBUG
45 45
 /*#define	NDEBUG	/* map CLAMAV debug onto standard */
... ...
@@ -631,6 +634,10 @@ messageToBlob(const message *m)
631 631
 		data = blobGetData(tmp);
632 632
 		len = blobGetDataSize(tmp);
633 633
 
634
+		/*
635
+		 * FIXME: this is dirty code, modification of the contents
636
+		 * of a member of the blob object should be done through blob.c
637
+		 */
634 638
 		if(data[0] == ':') {
635 639
 			char *ptr;
636 640
 			unsigned long newlen = 0L;
... ...
@@ -646,10 +653,10 @@ messageToBlob(const message *m)
646 646
 
647 647
 			for(l = 1; l < len; l++) {
648 648
 				unsigned char c = ptr[l];
649
-				char *tptr;
649
+				const unsigned char *tptr;
650 650
 
651 651
 				/* TODO: table look up would be quicker */
652
-				const char table[] =
652
+				const unsigned char table[] =
653 653
 					"!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
654 654
 
655 655
 				if((c == '\n') || (c == '\r'))
... ...
@@ -757,9 +764,9 @@ messageToBlob(const message *m)
757 757
 		/*
758 758
 		 * Discard attachments with no filename
759 759
 		 */
760
-		filename = messageFindArgument(m, "filename");
760
+		filename = (char *)messageFindArgument(m, "filename");
761 761
 		if(filename == NULL) {
762
-			filename = messageFindArgument(m, "name");
762
+			filename = (char *)messageFindArgument(m, "name");
763 763
 
764 764
 			if(filename == NULL) {
765 765
 				cli_dbgmsg("Attachment sent with no filename\n");