Minor code tidy

git-svn: trunk@957
remotes/push_mirror/metadata
Nigel Horne 22 years ago
parent 22080fa57c
commit 7c5a7a47f0
  1. 7
      clamav-devel/libclamav/blob.c
  2. 17
      clamav-devel/libclamav/mbox.c
  3. 38
      clamav-devel/libclamav/message.c
  4. 25
      clamav-devel/libclamav/table.c
  5. 9
      clamav-devel/libclamav/untar.c

@ -16,6 +16,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: blob.c,v $
* Revision 1.24 2004/10/01 13:50:47 nigelhorne
* Minor code tidy
*
* Revision 1.23 2004/09/21 09:26:35 nigelhorne
* Closing a closed blob is no longer fatal
*
@ -71,7 +74,7 @@
* Change LOG to Log
*
*/
static char const rcsid[] = "$Id: blob.c,v 1.23 2004/09/21 09:26:35 nigelhorne Exp $";
static char const rcsid[] = "$Id: blob.c,v 1.24 2004/10/01 13:50:47 nigelhorne Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -83,7 +86,7 @@ static char const rcsid[] = "$Id: blob.c,v 1.23 2004/09/21 09:26:35 nigelhorne E
#include <errno.h>
#include <fcntl.h>
#include <sys/param.h> /* for NAME_MAX */
#include <sys/param.h> /* for NAME_MAX */
#if C_DARWIN
#include <sys/types.h>

@ -17,6 +17,9 @@
*
* Change History:
* $Log: mbox.c,v $
* Revision 1.145 2004/10/01 13:49:22 nigelhorne
* Minor code tidy
*
* Revision 1.144 2004/10/01 07:55:36 nigelhorne
* Better error message on message/partial
*
@ -420,7 +423,7 @@
* Compilable under SCO; removed duplicate code with message.c
*
*/
static char const rcsid[] = "$Id: mbox.c,v 1.144 2004/10/01 07:55:36 nigelhorne Exp $";
static char const rcsid[] = "$Id: mbox.c,v 1.145 2004/10/01 13:49:22 nigelhorne Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -1029,6 +1032,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
/* Anything left to be parsed? */
if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
mime_type mimeType;
int subtype;
const char *mimeSubtype;
const text *t_line;
/*bool isAlternative;*/
@ -1040,13 +1044,15 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
mimeType = messageGetMimeType(mainMessage);
mimeSubtype = messageGetMimeSubtype(mainMessage);
if((mimeType == TEXT) && (tableFind(subtypeTable, mimeSubtype) == PLAIN)) {
subtype = tableFind(subtypeTable, mimeSubtype);
if((mimeType == TEXT) && (subtype == PLAIN)) {
/*
* This is effectively no encoding, notice that we
* don't check that charset is us-ascii
*/
cli_dbgmsg("assume no encoding\n");
mimeType = NOMIME;
messageSetMimeSubtype(mainMessage, NULL);
}
cli_dbgmsg("mimeType = %d\n", mimeType);
@ -1056,7 +1062,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
aText = textAddMessage(aText, mainMessage);
break;
case TEXT:
if(tableFind(subtypeTable, mimeSubtype) == PLAIN)
if(subtype == PLAIN)
/*
* Consider what to do if this fails
* (i.e. aText == NULL):
@ -1067,9 +1073,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
* able to scan anyway and we lose nothing
*/
aText = textCopy(messageGetBody(mainMessage));
else if(options&CL_SCAN_MAILURL)
if(tableFind(subtypeTable, mimeSubtype) == HTML)
checkURLs(mainMessage, dir);
else if((options&CL_SCAN_MAILURL) && (subtype == HTML))
checkURLs(mainMessage, dir);
break;
case MULTIPART:
boundary = messageFindArgument(mainMessage, "boundary");

@ -17,6 +17,9 @@
*
* Change History:
* $Log: message.c,v $
* Revision 1.93 2004/10/01 13:49:22 nigelhorne
* Minor code tidy
*
* Revision 1.92 2004/09/30 08:58:56 nigelhorne
* Remove empty lines
*
@ -273,7 +276,7 @@
* uuencodebegin() no longer static
*
*/
static char const rcsid[] = "$Id: message.c,v 1.92 2004/09/30 08:58:56 nigelhorne Exp $";
static char const rcsid[] = "$Id: message.c,v 1.93 2004/10/01 13:49:22 nigelhorne Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -975,7 +978,7 @@ messageAddStr(message *m, const char *data)
if(data) {
int isblank = 1;
char *p;
const char *p;
for(p = data; *p != '\0'; p++)
if(!isspace(*p)) {
@ -1414,7 +1417,6 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
if(filename == NULL) {
cli_dbgmsg("Attachment sent with no filename\n");
messageAddArgument(m, "name=attachment");
filename = strdup("attachment");
} else
/*
* Some virus attachments don't say how they've
@ -1423,9 +1425,10 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
messageSetEncoding(m, "base64");
}
(*setFilename)(ret, dir, filename);
(*setFilename)(ret, dir, (filename) ? filename : "attachment");
free((char *)filename);
if(filename)
free((char *)filename);
if(m->numberOfEncTypes == 0) {
if(uuencodeBegin(m))
@ -1478,11 +1481,13 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
strstrip(filename);
cli_dbgmsg("Set yEnc filename to \"%s\"\n", filename);
}
} else
filename = strdup("attachment");
}
if(filename)
(*setFilename)(ret, dir, filename);
(*setFilename)(ret, dir, (filename) ? filename : "attchment");
if(filename) {
free((char *)filename);
filename = NULL;
}
t_line = t_line->t_next;
enctype = YENCODE;
} else {
@ -1493,7 +1498,6 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
if(filename == NULL) {
cli_dbgmsg("Attachment sent with no filename\n");
messageAddArgument(m, "name=attachment");
filename = strdup("attachment");
} else if(enctype == NOENCODING)
/*
* Some virus attachments don't say how they've
@ -1502,7 +1506,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
messageSetEncoding(m, "base64");
}
(*setFilename)(ret, dir, filename);
(*setFilename)(ret, dir, (filename) ? filename : "attchment");
t_line = messageGetBody(m);
}
@ -1542,7 +1546,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
} else if(enctype == YENCODE) {
if(line == NULL)
continue;
if(strncmp(line, "=end ", 5) == 0)
if(strncmp(line, "=yend ", 6) == 0)
break;
}
@ -1746,11 +1750,13 @@ messageToText(message *m)
* strcmp - that'd be bad for MIME decoders, but is OK
* for AV software
*/
if(line && (strncmp(data, line, strlen(line)) == 0)) {
if((data[0] == '\n') || (data[0] == '\0'))
last->t_line = NULL;
else if(line && (strncmp(data, line, strlen(line)) == 0)) {
cli_dbgmsg("messageToText: decoded line is the same(%s)\n", data);
last->t_line = lineLink(t_line->t_line);
} else
last->t_line = ((data[0] != '\n') && data[0]) ? lineCreate((char *)data) : NULL;
last->t_line = lineCreate((char *)data);
if(line && enctype == BASE64)
if(strchr(line, '='))
@ -1760,7 +1766,7 @@ messageToText(message *m)
unsigned char data[4];
memset(data, '\0', sizeof(data));
if(decode(m, NULL, data, base64, FALSE)) {
if(decode(m, NULL, data, base64, FALSE) && data[0]) {
if(first == NULL)
first = last = cli_malloc(sizeof(text));
else {
@ -1769,7 +1775,7 @@ messageToText(message *m)
}
if(last != NULL)
last->t_line = data[0] ? lineCreate((char *)data) : NULL;
last->t_line = lineCreate((char *)data);
}
m->base64chars = 0;
}

@ -16,6 +16,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#ifndef CL_DEBUG
#define NDEBUG /* map CLAMAV debug onto standard */
#endif
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@ -89,6 +97,9 @@ int
tableFind(const table_t *table, const char *key)
{
const tableEntry *tableItem;
#ifdef CL_DEBUG
int cost;
#endif
assert(table != NULL);
@ -98,9 +109,19 @@ tableFind(const table_t *table, const char *key)
if(table->tableHead == NULL)
return -1; /* not populated yet */
for(tableItem = table->tableHead; tableItem; tableItem = tableItem->next)
if(strcasecmp(tableItem->key, key) == 0)
cost = 0;
for(tableItem = table->tableHead; tableItem; tableItem = tableItem->next) {
#ifdef CL_DEBUG
cost++;
#endif
if(strcasecmp(tableItem->key, key) == 0) {
#ifdef CL_DEBUG
cli_dbgmsg("tableFind: Cost of '%s' = %d\n", key, cost);
#endif
return(tableItem->value);
}
}
return -1; /* not found */
}

@ -20,6 +20,9 @@
*
* Change History:
* $Log: untar.c,v $
* Revision 1.11 2004/10/01 13:50:47 nigelhorne
* Minor code tidy
*
* Revision 1.10 2004/09/20 13:37:44 kojm
* 0.80rc
*
@ -51,7 +54,7 @@
* First draft
*
*/
static char const rcsid[] = "$Id: untar.c,v 1.10 2004/09/20 13:37:44 kojm Exp $";
static char const rcsid[] = "$Id: untar.c,v 1.11 2004/10/01 13:50:47 nigelhorne Exp $";
#include <stdio.h>
#include <errno.h>
@ -59,7 +62,7 @@ static char const rcsid[] = "$Id: untar.c,v 1.10 2004/09/20 13:37:44 kojm Exp $"
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/param.h> /* for NAME_MAX */
#include <sys/param.h> /* for NAME_MAX */
#include "clamav.h"
#include "others.h"
@ -137,7 +140,7 @@ cli_untar(const char *dir, int desc)
outfile = (FILE*)0;
}
if(block[0] == '\0') /* We're done */
if(block[0] == '\0') /* We're done */
break;
/* Notice assumption that BLOCKSIZE > 262 */

Loading…
Cancel
Save