git-svn: trunk@2292
Nigel Horne authored on 2006/09/20 19:24:17... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Wed Sep 20 11:22:56 BST 2006 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: Removed some multiple calls to blobClose() and added one |
|
4 |
+ byte to arrays which other libraries may have offset |
|
5 |
+ by one issues with |
|
6 |
+ |
|
1 | 7 |
Mon Sep 18 14:41:10 BST 2006 (njh) |
2 | 8 |
---------------------------------- |
3 | 9 |
* contrib/Windows/Projects/clamAV/libclamav: Fixed support for 64 bit in |
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: blob.c,v 1.53 2006/08/27 09:51:31 njh Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: blob.c,v 1.54 2006/09/20 10:22:07 njh Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -249,7 +249,7 @@ blobClose(blob *b) |
249 | 249 |
assert(b->magic == BLOBCLASS); |
250 | 250 |
|
251 | 251 |
if(b->isClosed) { |
252 |
- cli_dbgmsg("Attempt to close a previously closed blob\n"); |
|
252 |
+ cli_warnmsg("Attempt to close a previously closed blob\n"); |
|
253 | 253 |
return; |
254 | 254 |
} |
255 | 255 |
|
... | ... |
@@ -428,10 +428,9 @@ void html_tag_arg_free(tag_arguments_t *tags) |
428 | 428 |
*/ |
429 | 429 |
static inline void html_tag_set_inahref(tag_arguments_t *tags,int idx,int in_ahref) |
430 | 430 |
{ |
431 |
- char x[]=""; |
|
432 | 431 |
tags->contents[idx-1]=blobCreate(); |
433 | 432 |
blobAddData(tags->contents[idx-1],tags->value[in_ahref-1],strlen(tags->value[in_ahref-1])); |
434 |
- blobAddData(tags->contents[idx-1],x,1); |
|
433 |
+ blobAddData(tags->contents[idx-1], "",1); |
|
435 | 434 |
blobClose(tags->contents[idx-1]); |
436 | 435 |
} |
437 | 436 |
|
... | ... |
@@ -448,8 +447,8 @@ static inline void html_tag_contents_append(tag_arguments_t *tags,int idx,const |
448 | 448 |
|
449 | 449 |
static inline void html_tag_contents_done(tag_arguments_t *tags,int idx) |
450 | 450 |
{ |
451 |
- char x[]=""; |
|
452 |
- blobAddData(tags->contents[idx-1],x,1);/*append NULL character*/ |
|
451 |
+ /* append NUL byte */ |
|
452 |
+ blobAddData(tags->contents[idx-1], "", 1); |
|
453 | 453 |
blobClose(tags->contents[idx-1]); |
454 | 454 |
} |
455 | 455 |
|
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: mbox.c,v 1.336 2006/09/18 16:58:39 njh Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: mbox.c,v 1.337 2006/09/20 10:22:07 njh Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -139,7 +139,6 @@ typedef enum { FALSE = 0, TRUE = 1 } bool; |
139 | 139 |
|
140 | 140 |
#ifdef FOLLOWURLS |
141 | 141 |
|
142 |
- |
|
143 | 142 |
#ifdef WITH_CURL /* Set in configure */ |
144 | 143 |
/* |
145 | 144 |
* To build with WITH_CURL: |
... | ... |
@@ -1941,6 +1940,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx) |
1941 | 1941 |
#ifdef CL_EXPERIMENTAL |
1942 | 1942 |
const int doPhishingScan = !(mctx->ctx->options&CL_SCAN_NOPHISHING); /* || (mctx->ctx->options&CL_SCAN_PHISHING_GA_TRAIN) || (mctx->ctx->options&CL_SCAN_PHISHING_GA); kept here for the GA MERGE */ |
1943 | 1943 |
#endif |
1944 |
+ |
|
1944 | 1945 |
cli_dbgmsg("in parseEmailBody\n"); |
1945 | 1946 |
|
1946 | 1947 |
/* Anything left to be parsed? */ |
... | ... |
@@ -3761,7 +3761,7 @@ hrefs_done(blob *b, tag_arguments_t *hrefs) |
3761 | 3761 |
static blob * |
3762 | 3762 |
getHrefs(message *m, tag_arguments_t *hrefs) |
3763 | 3763 |
{ |
3764 |
- blob *b = messageToBlob(m,0); |
|
3764 |
+ blob *b = messageToBlob(m, 0); |
|
3765 | 3765 |
size_t len; |
3766 | 3766 |
|
3767 | 3767 |
if(b == NULL) |
... | ... |
@@ -3781,18 +3781,16 @@ getHrefs(message *m, tag_arguments_t *hrefs) |
3781 | 3781 |
return NULL; |
3782 | 3782 |
} |
3783 | 3783 |
|
3784 |
- blobClose(b); |
|
3785 |
- |
|
3786 | 3784 |
hrefs->count = 0; |
3787 | 3785 |
hrefs->tag = hrefs->value = NULL; |
3788 | 3786 |
hrefs->contents = NULL; |
3789 | 3787 |
|
3790 |
- cli_dbgmsg("checkURLs: calling html_normalise_mem\n"); |
|
3788 |
+ cli_dbgmsg("getHrefs: calling html_normalise_mem\n"); |
|
3791 | 3789 |
if(!html_normalise_mem(blobGetData(b), len, NULL, hrefs)) { |
3792 | 3790 |
blobDestroy(b); |
3793 | 3791 |
return NULL; |
3794 | 3792 |
} |
3795 |
- cli_dbgmsg("checkURLs: html_normalise_mem returned\n"); |
|
3793 |
+ cli_dbgmsg("getHrefs: html_normalise_mem returned\n"); |
|
3796 | 3794 |
|
3797 | 3795 |
/* TODO: Do we need to call remove_html_comments? */ |
3798 | 3796 |
return b; |
... | ... |
@@ -3972,7 +3970,7 @@ do_checkURLs(message *m, const char *dir, tag_arguments_t *hrefs) |
3972 | 3972 |
|
3973 | 3973 |
#if defined(FOLLOWURLS) && (FOLLOWURLS > 0) |
3974 | 3974 |
static void |
3975 |
-checkURLs(message *m, mbox_ctx *mctx, int* rc, int is_html) |
|
3975 |
+checkURLs(message *m, mbox_ctx *mctx, int *rc, int is_html) |
|
3976 | 3976 |
{ |
3977 | 3977 |
blob *b = messageToBlob(m, 0); |
3978 | 3978 |
size_t len; |
... | ... |
@@ -4001,7 +3999,6 @@ checkURLs(message *m, mbox_ctx *mctx, int* rc, int is_html) |
4001 | 4001 |
return; |
4002 | 4002 |
} |
4003 | 4003 |
|
4004 |
- blobClose(b); |
|
4005 | 4004 |
t = tableCreate(); |
4006 | 4005 |
if(t == NULL) { |
4007 | 4006 |
blobDestroy(b); |
... | ... |
@@ -4176,7 +4173,7 @@ getURL(struct arg *arg) |
4176 | 4176 |
const char *filename = arg->filename; |
4177 | 4177 |
char fout[NAME_MAX + 1]; |
4178 | 4178 |
#ifdef CURLOPT_ERRORBUFFER |
4179 |
- char errorbuffer[CURL_ERROR_SIZE]; |
|
4179 |
+ char errorbuffer[CURL_ERROR_SIZE + 1]; |
|
4180 | 4180 |
#elif (LIBCURL_VERSION_NUM >= 0x070C00) |
4181 | 4181 |
CURLcode res = CURLE_OK; |
4182 | 4182 |
#endif |
... | ... |
@@ -4201,19 +4198,19 @@ getURL(struct arg *arg) |
4201 | 4201 |
/* easy isn't the word I'd use... */ |
4202 | 4202 |
curl = curl_easy_init(); |
4203 | 4203 |
if(curl == NULL) { |
4204 |
- cli_errmsg("curl_easy_init failed"); |
|
4204 |
+ cli_errmsg("curl_easy_init failed\n"); |
|
4205 | 4205 |
return NULL; |
4206 | 4206 |
} |
4207 | 4207 |
|
4208 | 4208 |
(void)curl_easy_setopt(curl, CURLOPT_USERAGENT, "www.clamav.net"); |
4209 | 4209 |
|
4210 | 4210 |
if(curl_easy_setopt(curl, CURLOPT_URL, url) != 0) { |
4211 |
- cli_errmsg("%s: curl_easy_setopt failed", url); |
|
4211 |
+ cli_errmsg("%s: curl_easy_setopt failed\n", url); |
|
4212 | 4212 |
curl_easy_cleanup(curl); |
4213 | 4213 |
return NULL; |
4214 | 4214 |
} |
4215 | 4215 |
|
4216 |
- snprintf(fout, NAME_MAX, "%s/%s", dir, filename); |
|
4216 |
+ snprintf(fout, sizeof(fout) - 1, "%s/%s", dir, filename); |
|
4217 | 4217 |
|
4218 | 4218 |
fp = fopen(fout, "wb"); |
4219 | 4219 |
|
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: message.c,v 1.186 2006/09/16 09:53:56 njh Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: message.c,v 1.187 2006/09/20 10:22:07 njh Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -1579,7 +1579,7 @@ messageToFileblob(message *m, const char *dir, int destroy) |
1579 | 1579 |
} |
1580 | 1580 |
|
1581 | 1581 |
/* |
1582 |
- * Decode and transfer the contents of the message into a blob |
|
1582 |
+ * Decode and transfer the contents of the message into a closed blob |
|
1583 | 1583 |
* The caller must free the returned blob |
1584 | 1584 |
*/ |
1585 | 1585 |
blob * |