Various cleanups

git-svn: trunk@3207
remotes/push_mirror/metadata
Nigel Horne 18 years ago
parent 641dbe1f37
commit 8affc4062b
  1. 8
      clamav-milter/clamav-milter.c
  2. 18
      libclamav/blob.c
  3. 19
      libclamav/mbox.c
  4. 11
      libclamav/message.c
  5. 1
      libclamav/message.h
  6. 20
      libclamav/pdf.c

@ -3291,7 +3291,7 @@ clamfi_eom(SMFICTX *ctx)
for(i = privdata->statusCount; i > 0; --i)
if(smfi_chgheader(ctx, "X-Virus-Status", i, NULL) == MI_FAILURE)
logg(_("^Failed to delete X-Virus-Status header %d"), i);
logg(_("^Failed to delete X-Virus-Status header %d\n"), i);
}
if(!external) {
@ -3346,7 +3346,7 @@ clamfi_eom(SMFICTX *ctx)
if(send(session->sock, cmdbuf, nbytes, 0) < nbytes) {
perror("send");
clamfi_cleanup(ctx);
logg(_("failed to send SCAN %s command to clamd"), privdata->filename);
logg(_("failed to send SCAN %s command to clamd\n"), privdata->filename);
return cl_error;
}
#else
@ -3367,7 +3367,7 @@ clamfi_eom(SMFICTX *ctx)
if(send(privdata->cmdSocket, cmdbuf, nbytes, 0) < nbytes) {
perror("send");
clamfi_cleanup(ctx);
logg(_("failed to send SCAN command to clamd"));
logg(_("failed to send SCAN command to clamd\n"));
return cl_error;
}
@ -3414,7 +3414,7 @@ clamfi_eom(SMFICTX *ctx)
*/
clamfi_cleanup(ctx);
logg(_("clamfi_eom: read nothing from clamd on %s"), hostname);
logg(_("clamfi_eom: read nothing from clamd on %s\n"), hostname);
#ifdef SESSION
pthread_mutex_lock(&sstatus_mutex);

@ -446,7 +446,8 @@ fileblobDestroy(fileblob *fb)
} else if(fb->b.data) {
free(fb->b.data);
if(fb->b.name) {
cli_errmsg("fileblobDestroy: %s not saved: report to http://bugs.clamav.net\n", fb->b.name);
cli_errmsg("fileblobDestroy: %s not saved: report to http://bugs.clamav.net\n",
(fb->fullname) ? fb->fullname : fb->b.name);
free(fb->b.name);
} else
cli_errmsg("fileblobDestroy: file not saved (%lu bytes): report to http://bugs.clamav.net\n",
@ -633,21 +634,30 @@ fileblobSetCTX(fileblob *fb, cli_ctx *ctx)
int
fileblobScan(const fileblob *fb)
{
#ifndef C_WINDOWS
int rc, fd;
#endif
if(fb->isInfected)
return CL_VIRUS;
if(fb->fullname == NULL) {
/* shouldn't happen, scan called before fileblobSetFilename */
cli_warnmsg("fileblobScan, fullname == NULL\n");
return CL_CLEAN; /* there is no CL_UNKNOWN */
return CL_ENULLARG; /* there is no CL_UNKNOWN */
}
if(fb->ctx == NULL) {
/* fileblobSetCTX hasn't been called */
cli_dbgmsg("fileblobScan, ctx == NULL\n");
return CL_CLEAN; /* there is no CL_UNKNOWN */
}
#ifndef C_WINDOWS
/*
* FIXME: On Windows, cli_readn gives "bad file descriptor" when called
* by cli_check_mydoom_log from a call do cli_magic_scandesc here which
* implies that the file descriptor is getting closed somewhere, but I
* can't see where.
* One possible fix would be to duplicate cli_scanfile here.
*/
fflush(fb->fp);
fd = dup(fileno(fb->fp));
if(fd == -1) {
@ -662,11 +672,13 @@ fileblobScan(const fileblob *fb)
rc = cli_magic_scandesc(fd, fb->ctx);
close(fd);
if(rc == CL_VIRUS) {
cli_dbgmsg("%s is infected\n", fb->fullname);
return CL_VIRUS;
}
cli_dbgmsg("%s is clean\n", fb->fullname);
#endif /*C_WINDOWS*/
return CL_BREAK;
}

@ -2031,7 +2031,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
mimeType = NOMIME;
messageSetMimeSubtype(mainMessage, "");
} else
cli_dbgmsg("mimeType = %d\n", mimeType);
cli_dbgmsg("mimeType = %d\n", (int)mimeType);
switch(mimeType) {
case NOMIME:
@ -2413,7 +2413,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
} while((t_line = t_line->t_next) != NULL);
cli_dbgmsg("Part %d has %d lines, rc = %d\n",
multiparts, lines, rc);
multiparts, lines, (int)rc);
/*
* Only save in the array of messages if some
@ -2975,7 +2975,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
if(saveIt) {
cli_dbgmsg("Saving text part to scan, rc = %d\n",
rc);
(int)rc);
if(saveTextPart(mainMessage, mctx->dir, 1) == CL_VIRUS)
rc = VIRUS;
@ -2995,7 +2995,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
if((rc != FAIL) && infected)
rc = VIRUS;
cli_dbgmsg("parseEmailBody() returning %d\n", rc);
cli_dbgmsg("parseEmailBody() returning %d\n", (int)rc);
return rc;
}
@ -3623,7 +3623,7 @@ rfc2047(const char *in)
b = messageToBlob(m, 1);
len = blobGetDataSize(b);
cli_dbgmsg("Decoded as '%*.*s'\n", (int)len, (int)len,
blobGetData(b));
(const char *)blobGetData(b));
memcpy(pout, blobGetData(b), len);
blobDestroy(b);
messageDestroy(m);
@ -3932,6 +3932,11 @@ checkURLs(message *mainMessage, mbox_ctx *mctx, mbox_status *rc, int is_html)
if(b) {
if(hrefs.scanContents) {
if(phishingScan(mainMessage, mctx->dir, mctx->ctx, &hrefs) == CL_VIRUS) {
/*
* FIXME: message objects' contents are
* encapsulated so we should not access
* the members directly
*/
mainMessage->isInfected = TRUE;
*rc = VIRUS;
cli_dbgmsg("PH:Phishing found\n");
@ -4703,7 +4708,7 @@ isBounceStart(const char *line)
do
if(*line == ' ')
numSpaces++;
else if(isdigit(*line))
else if(isdigit((*line) & 0xFF))
numDigits++;
while(*++line != '\0');
@ -5005,7 +5010,7 @@ do_multipart(message *mainMessage, message **messages, int i, mbox_status *rc, m
* whole multipart section
*/
*rc = parseEmailBody(aMessage, *tptr, mctx, recursion_level + 1);
cli_dbgmsg("Finished recursion, rc = %d\n", *rc);
cli_dbgmsg("Finished recursion, rc = %d\n", (int)*rc);
assert(aMessage == messages[i]);
messageDestroy(messages[i]);
messages[i] = NULL;

@ -297,7 +297,8 @@ messageSetMimeType(message *mess, const char *type)
}
if(highestSimil >= 50) {
cli_dbgmsg("Unknown MIME type \"%s\" - guessing as %s (%u%% certainty)\n",
type, closest, highestSimil);
type, closest,
(int)highestSimil);
mess->mimeType = (mime_type)t;
} else {
cli_dbgmsg("Unknown MIME type: `%s', set to Application - if you believe this file contains a virus, submit it to www.clamav.net\n", type);
@ -1405,7 +1406,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
(*destroy)(ret);
ret = newret;
}
cli_dbgmsg("messageExport: enctype %d is %d\n", i, enctype);
cli_dbgmsg("messageExport: enctype %d is %d\n", i, (int)enctype);
/*
* Find the filename to decode
*/
@ -1553,7 +1554,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
} while((t_line = t_line->t_next) != NULL);
cli_dbgmsg("Exported %lu bytes using enctype %d\n",
(unsigned long)size, enctype);
(unsigned long)size, (int)enctype);
/* Verify we have nothing left to flush out */
if(m->base64chars) {
@ -1572,7 +1573,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
unsigned char *
base64Flush(message *m, unsigned char *buf)
{
cli_dbgmsg("%u trailing bytes to export\n", m->base64chars);
cli_dbgmsg("%d trailing bytes to export\n", m->base64chars);
if(m->base64chars) {
unsigned char *ret = decode(m, NULL, buf, base64, FALSE);
@ -1684,7 +1685,7 @@ messageToText(message *m)
const encoding_type enctype = m->encodingTypes[i];
cli_dbgmsg("messageToText: export transfer method %d = %d\n",
i, enctype);
i, (int)enctype);
switch(enctype) {
case NOENCODING:

@ -20,6 +20,7 @@
#ifndef _MESSAGE_H
#define _MESSAGE_H
/* The contents could change, ONLY access in message.c */
typedef struct message {
mime_type mimeType;
encoding_type *encodingTypes;

@ -75,7 +75,7 @@ int
cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
{
off_t size; /* total number of bytes in the file */
long bytesleft, trailerlength;
off_t bytesleft, trailerlength;
char *buf, *alloced; /* start of memory mapped area */
const char *p, *q, *trailerstart;
const char *xrefstart; /* cross reference table */
@ -229,7 +229,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
break;
/*object_number = atoi(q);*/
bytesleft -= (q - p);
bytesleft -= (off_t)(q - p);
p = q;
if(memcmp(q, "endobj", 6) == 0)
@ -246,7 +246,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
break;
}
/*generation_number = atoi(q);*/
bytesleft -= (q - p);
bytesleft -= (off_t)(q - p);
p = q;
q = pdf_nextobject(p, bytesleft);
@ -256,14 +256,14 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
break;
}
bytesleft -= (q - p) + 3;
bytesleft -= (off_t)((q - p) + 3);
objstart = p = &q[3];
objend = cli_pmemstr(p, bytesleft, "endobj", 6);
if(objend == NULL) {
cli_dbgmsg("No matching endobj\n");
break;
}
bytesleft -= (objend - p) + 6;
bytesleft -= (off_t)((objend - p) + 6);
p = &objend[6];
objlen = (unsigned long)(objend - objstart);
@ -672,9 +672,13 @@ flatedecode(unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
if(cli_writen(fout, output, sizeof(output) - stream.avail_out) < 0)
return Z_STREAM_ERROR;
cli_dbgmsg("cli_pdf: flatedecode in=%lu out=%lu ratio %ld (max %d)\n",
stream.total_in, stream.total_out,
stream.total_out / stream.total_in,
/*
* On BSD systems total_in and total_out are "long long", so these
* numbers could (in theory) get truncated in the debug statement
*/
cli_dbgmsg("cli_pdf: flatedecode in=%lu out=%lu ratio %lu (max %u)\n",
(unsigned long)stream.total_in, (unsigned long)stream.total_out,
(unsigned long)(stream.total_out / stream.total_in),
ctx->limits ? ctx->limits->maxratio : 0);
if(ctx->limits &&

Loading…
Cancel
Save