git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@140 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2003/12/05 18:35:30... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Fri Dec 5 09:34:44 GMT 2003 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: Use cli_tok instead of strtok - replaced now by cli_strtok |
|
4 |
+ |
|
1 | 5 |
Fri Dec 5 02:31:24 CET 2003 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* clamav-milter: Makefile: link against libclamav (needed for cli_strtok()) |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.12 2003/12/05 09:34:00 nigelhorne |
|
21 |
+ * Use cli_tok instead of strtok - replaced now by cli_strtok |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.11 2003/11/17 07:57:12 nigelhorne |
21 | 24 |
* Prevent buffer overflow in broken uuencoded files |
22 | 25 |
* |
... | ... |
@@ -30,15 +33,17 @@ |
30 | 30 |
* uuencodebegin() no longer static |
31 | 31 |
* |
32 | 32 |
*/ |
33 |
-static char const rcsid[] = "$Id: message.c,v 1.11 2003/11/17 07:57:12 nigelhorne Exp $"; |
|
33 |
+static char const rcsid[] = "$Id: message.c,v 1.12 2003/12/05 09:34:00 nigelhorne Exp $"; |
|
34 | 34 |
|
35 | 35 |
#ifndef CL_DEBUG |
36 | 36 |
/*#define NDEBUG /* map CLAMAV debug onto standard */ |
37 | 37 |
#endif |
38 | 38 |
|
39 | 39 |
#ifdef CL_THREAD_SAFE |
40 |
+#ifndef _REENTRANT |
|
40 | 41 |
#define _REENTRANT /* for Solaris 2.8 */ |
41 | 42 |
#endif |
43 |
+#endif |
|
42 | 44 |
|
43 | 45 |
#if C_DARWIN |
44 | 46 |
#include <sys/types.h> |
... | ... |
@@ -60,12 +65,7 @@ static char const rcsid[] = "$Id: message.c,v 1.11 2003/11/17 07:57:12 nigelhorn |
60 | 60 |
#include "text.h" |
61 | 61 |
#include "strrcpy.h" |
62 | 62 |
#include "others.h" |
63 |
- |
|
64 |
-#if defined(NO_STRTOK_R) || !defined(CL_THREAD_SAFE) |
|
65 |
-#undef strtok_r |
|
66 |
-#undef __strtok_r |
|
67 |
-#define strtok_r(a,b,c) strtok(a,b) |
|
68 |
-#endif |
|
63 |
+#include "str.h" |
|
69 | 64 |
|
70 | 65 |
/* required for AIX and Tru64 */ |
71 | 66 |
#ifdef TRUE |
... | ... |
@@ -276,7 +276,7 @@ messageAddArgument(message *m, const char *arg) |
276 | 276 |
|
277 | 277 |
if(offset == m->numberOfArguments) { |
278 | 278 |
m->numberOfArguments++; |
279 |
- m->mimeArguments = (char **)realloc(m->mimeArguments, m->numberOfArguments * sizeof(char *)); |
|
279 |
+ m->mimeArguments = (char **)cli_realloc(m->mimeArguments, m->numberOfArguments * sizeof(char *)); |
|
280 | 280 |
} |
281 | 281 |
|
282 | 282 |
m->mimeArguments[offset] = strdup(arg); |
... | ... |
@@ -571,7 +571,7 @@ messageToBlob(const message *m) |
571 | 571 |
{ |
572 | 572 |
blob *b; |
573 | 573 |
const text *t_line = NULL; |
574 |
- const char *filename; |
|
574 |
+ char *filename; |
|
575 | 575 |
|
576 | 576 |
assert(m != NULL); |
577 | 577 |
|
... | ... |
@@ -583,11 +583,6 @@ messageToBlob(const message *m) |
583 | 583 |
* Find the filename to decode |
584 | 584 |
*/ |
585 | 585 |
if(messageGetEncoding(m) == UUENCODE) { |
586 |
- char *copy; |
|
587 |
-#ifdef CL_THREAD_SAFE |
|
588 |
- char *strptr; |
|
589 |
-#endif |
|
590 |
- |
|
591 | 586 |
t_line = uuencodeBegin(m); |
592 | 587 |
|
593 | 588 |
if(t_line == NULL) { |
... | ... |
@@ -596,22 +591,18 @@ messageToBlob(const message *m) |
596 | 596 |
return NULL; |
597 | 597 |
} |
598 | 598 |
|
599 |
- copy = strdup(t_line->t_text); |
|
600 |
- (void)strtok_r(copy, " ", &strptr); |
|
601 |
- (void)strtok_r(NULL, " ", &strptr); |
|
602 |
- filename = strtok_r(NULL, "\r\n", &strptr); |
|
599 |
+ filename = cli_strtok(t_line->t_text, 2, " "); |
|
603 | 600 |
|
604 | 601 |
if(filename == NULL) { |
605 | 602 |
cli_dbgmsg("UUencoded attachment sent with no filename\n"); |
606 | 603 |
blobDestroy(b); |
607 |
- free(copy); |
|
608 | 604 |
return NULL; |
609 | 605 |
} |
606 |
+ cli_chomp(filename); |
|
610 | 607 |
|
611 | 608 |
cli_dbgmsg("Set uuencode filename to \"%s\"\n", filename); |
612 | 609 |
|
613 | 610 |
blobSetFilename(b, filename); |
614 |
- free(copy); |
|
615 | 611 |
t_line = t_line->t_next; |
616 | 612 |
} else { |
617 | 613 |
/* |
... | ... |
@@ -630,9 +621,9 @@ messageToBlob(const message *m) |
630 | 630 |
|
631 | 631 |
blobSetFilename(b, filename); |
632 | 632 |
|
633 |
- free((char *)filename); |
|
634 | 633 |
t_line = messageGetBody(m); |
635 | 634 |
} |
635 |
+ free((char *)filename); |
|
636 | 636 |
|
637 | 637 |
/* |
638 | 638 |
* t_line should now point to the first (encoded) line of the message |
... | ... |
@@ -805,7 +796,7 @@ uuencodeBegin(const message *m) |
805 | 805 |
static unsigned char * |
806 | 806 |
decodeLine(const message *m, const char *line, unsigned char *buf, size_t buflen) |
807 | 807 |
{ |
808 |
- int len; |
|
808 |
+ size_t len; |
|
809 | 809 |
bool softbreak; |
810 | 810 |
char *p2; |
811 | 811 |
char *copy; |