Various tidy

git-svn: trunk@2719
remotes/push_mirror/metadata
Nigel Horne 19 years ago
parent db6d816658
commit 95e11e5abc
  1. 7
      clamav-devel/ChangeLog
  2. 7
      clamav-devel/libclamav/binhex.c
  3. 19
      clamav-devel/libclamav/blob.c
  4. 7
      clamav-devel/libclamav/line.c
  5. 32
      clamav-devel/libclamav/mbox.c
  6. 41
      clamav-devel/libclamav/message.c
  7. 21
      clamav-devel/libclamav/pdf.c
  8. 13
      clamav-devel/libclamav/text.c
  9. 7
      clamav-devel/libclamav/untar.c

@ -1,3 +1,8 @@
Mon Feb 12 20:46:27 GMT 2007 (njh)
----------------------------------
* libclamav: Fix various gcc warnings
* libclamav/mbox.c: sanitise rfc1341 names
Mon Feb 12 21:33:20 CET 2007 (tk)
---------------------------------
* libclamav/phishcheck.c: fix hexurl regex (bb#288)
@ -84,7 +89,7 @@ Fri Feb 9 22:25:24 CET 2007 (tk)
Fri Feb 9 21:12:28 CET 2007 (acab)
-----------------------------------
* libclamav: Fix win32 compilation error in upack and mew - thanks Nigel
Fri Feb 9 17:57:15 GMT 2007 (njh)
----------------------------------
* libclamav/lockdb.c: Fix compilation error, bug 234

@ -18,6 +18,9 @@
*
* Change History:
* $Log: binhex.c,v $
* Revision 1.23 2007/02/12 20:46:08 njh
* Various tidy
*
* Revision 1.22 2006/07/31 09:19:52 njh
* Use MAP_PRIVATE
*
@ -82,7 +85,7 @@
* First draft of binhex.c
*
*/
static char const rcsid[] = "$Id: binhex.c,v 1.22 2006/07/31 09:19:52 njh Exp $";
static char const rcsid[] = "$Id: binhex.c,v 1.23 2007/02/12 20:46:08 njh Exp $";
#include "clamav.h"
@ -197,7 +200,7 @@ cli_binhex(const char *dir, int desc)
cli_errmsg("No binhex line found\n");
return CL_EFORMAT;
}
/* similar to binhexMessage */
messageSetEncoding(m, "x-binhex");

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: blob.c,v 1.62 2007/02/10 14:21:46 njh Exp $";
static char const rcsid[] = "$Id: blob.c,v 1.63 2007/02/12 20:46:08 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -272,7 +272,7 @@ blobClose(blob *b)
free(b->data);
b->data = NULL;
cli_dbgmsg("blobClose: recovered all %lu bytes\n",
b->size);
(unsigned long)b->size);
b->size = 0;
} else {
unsigned char *ptr = cli_realloc(b->data, b->len);
@ -281,7 +281,8 @@ blobClose(blob *b)
return;
cli_dbgmsg("blobClose: recovered %lu bytes from %lu\n",
b->size - b->len, b->size);
(unsigned long)(b->size - b->len),
(unsigned long)b->size);
b->size = b->len;
b->data = ptr;
}
@ -390,7 +391,8 @@ fileblobDestroy(fileblob *fb)
cli_errmsg("fileblobDestroy: %s not saved: refer to http://www.clamav.net/bugs.html#pagestart\n", fb->b.name);
free(fb->b.name);
} else
cli_errmsg("fileblobDestroy: file not saved (%lu bytes): report to http://bugs.clamav.net\n", fb->b.len);
cli_errmsg("fileblobDestroy: file not saved (%lu bytes): report to http://bugs.clamav.net\n",
(unsigned long)fb->b.len);
}
#ifdef CL_DEBUG
fb->b.magic = INVALIDCLASS;
@ -468,7 +470,8 @@ fileblobSetFilename(fileblob *fb, const char *dir, const char *filename)
if(fd < 0) {
cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
cli_dbgmsg("%d %d\n", sizeof(fullname), strlen(fullname));
cli_dbgmsg("%lu %lu\n", (unsigned long)sizeof(fullname),
(unsigned long)strlen(fullname));
return;
}
@ -478,7 +481,8 @@ fileblobSetFilename(fileblob *fb, const char *dir, const char *filename)
if(fb->fp == NULL) {
cli_errmsg("Can't create file %s: %s\n", fullname, strerror(errno));
cli_dbgmsg("%d %d\n", sizeof(fullname), strlen(fullname));
cli_dbgmsg("%lu %lu\n", (unsigned long)sizeof(fullname),
(unsigned long)strlen(fullname));
close(fd);
return;
@ -528,7 +532,8 @@ fileblobAddData(fileblob *fb, const unsigned char *data, size_t len)
#endif
if(fwrite(data, len, 1, fb->fp) != 1) {
cli_errmsg("fileblobAddData: Can't write %u bytes to temporary file %s: %s\n", len, fb->b.name, strerror(errno));
cli_errmsg("fileblobAddData: Can't write %lu bytes to temporary file %s: %s\n",
(unsigned long)len, fb->b.name, strerror(errno));
return -1;
}
fb->isNotEmpty = 1;

@ -17,6 +17,9 @@
* MA 02110-1301, USA.
*
* $Log: line.c,v $
* Revision 1.11 2007/02/12 20:46:08 njh
* Various tidy
*
* Revision 1.10 2006/04/09 19:59:27 kojm
* update GPL headers with new address for FSF
*
@ -49,7 +52,7 @@
*
*/
static char const rcsid[] = "$Id: line.c,v 1.10 2006/04/09 19:59:27 kojm Exp $";
static char const rcsid[] = "$Id: line.c,v 1.11 2007/02/12 20:46:08 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -110,7 +113,9 @@ lineGetData(const line_t *line)
{
return line ? line->l_str : NULL;
}
#else
line_t *
lineCreate(const char *data)
{

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: mbox.c,v 1.373 2007/02/01 12:42:18 njh Exp $";
static char const rcsid[] = "$Id: mbox.c,v 1.374 2007/02/12 20:46:08 njh Exp $";
#ifdef _MSC_VER
#include <winsock.h> /* only needed in CL_EXPERIMENTAL */
@ -138,7 +138,7 @@ typedef enum {
* symbol in file
* __floatdidf /opt/sfw/lib/libcurl.s
*/
#if C_SOLARIS && __GNUC__
#if defined(C_SOLARIS) && defined(__GNUC__)
#undef WITH_CURL
#endif
#endif
@ -466,8 +466,6 @@ static void add_to_map(const char *offset, const char *word);
static const char *find_in_map(const char *offset, const char *word);
static void free_map(void);
/*
* This could be the future. Instead of parsing and decoding it just decodes.
*
@ -2061,8 +2059,8 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
mime_type mimeType;
int subtype, inhead, htmltextPart, inMimeHead, i;
const char *mimeSubtype, *boundary;
char *protocol;
const char *mimeSubtype;
char *protocol, *boundary;
const text *t_line;
/*bool isAlternative;*/
message *aMessage;
@ -2930,7 +2928,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
break;
cli_dbgmsg("Save non mime part bounce message\n");
fileblobSetFilename(fb, mctx->dir, "bounce");
fileblobAddData(fb, (unsigned char *)"Received: by clamd (bounce)\n", 28);
fileblobAddData(fb, (const unsigned char *)"Received: by clamd (bounce)\n", 28);
fileblobSetCTX(fb, mctx->ctx);
inheader = TRUE;
@ -2945,9 +2943,9 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
}
} else {
s = lineGetData(l);
fileblobAddData(fb, (unsigned char *)s, strlen(s));
fileblobAddData(fb, (const unsigned char *)s, strlen(s));
}
fileblobAddData(fb, (unsigned char *)"\n", 1);
fileblobAddData(fb, (const unsigned char *)"\n", 1);
lookahead = t->t_next;
if(lookahead == NULL)
break;
@ -3061,7 +3059,8 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
static int
boundaryStart(const char *line, const char *boundary)
{
char *ptr, *out;
const char *ptr;
char *out;
int rc;
char buf[RFC2821LENGTH + 1];
@ -3082,10 +3081,10 @@ boundaryStart(const char *line, const char *boundary)
out = NULL;
ptr = rfc822comments(line, buf);
} else
out = ptr = rfc822comments(line, NULL);
ptr = out = rfc822comments(line, NULL);
if(ptr == NULL)
ptr = (char *)line;
ptr = line;
if(*ptr++ != '-') {
if(out)
@ -3645,7 +3644,8 @@ rfc2047(const char *in)
}
b = messageToBlob(m, 1);
len = blobGetDataSize(b);
cli_dbgmsg("Decoded as '%*.*s'\n", len, len, blobGetData(b));
cli_dbgmsg("Decoded as '%*.*s'\n", (int)len, (int)len,
blobGetData(b));
memcpy(pout, blobGetData(b), len);
blobDestroy(b);
messageDestroy(m);
@ -3710,7 +3710,7 @@ rfc1341(message *m, const char *dir)
}
if(statb.st_mode & 077)
cli_warnmsg("Insecure partial directory %s (mode 0%o)\n",
pdir, statb.st_mode & 0777);
pdir, (int)(statb.st_mode & 0777));
}
number = (char *)messageFindArgument(m, "number");
@ -3760,6 +3760,8 @@ rfc1341(message *m, const char *dir)
char outname[NAME_MAX + 1];
time_t now;
sanitiseName(id);
snprintf(outname, sizeof(outname) - 1, "%s/%s", dir, id);
cli_dbgmsg("outname: %s\n", outname);
@ -3796,8 +3798,8 @@ rfc1341(message *m, const char *dir)
FILE *fin;
char buffer[BUFSIZ], fullname[NAME_MAX + 1];
int nblanks;
extern short cli_leavetemps_flag;
struct stat statb;
extern short cli_leavetemps_flag;
#ifndef C_CYGWIN
if(dent->d_ino == 0)

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: message.c,v 1.194 2007/02/10 14:21:46 njh Exp $";
static char const rcsid[] = "$Id: message.c,v 1.195 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -510,20 +510,20 @@ messageAddArguments(message *m, const char *s)
continue;
if(*cptr == '"') {
char *ptr;
char *ptr, *kcopy;
/*
* The field is in quotes, so look for the
* closing quotes
*/
key = cli_strdup(key);
kcopy = cli_strdup(key);
if(key == NULL)
if(kcopy == NULL)
return;
ptr = strchr(key, '=');
ptr = strchr(kcopy, '=');
if(ptr == NULL)
ptr = strchr(key, ':');
ptr = strchr(kcopy, ':');
*ptr = '\0';
string = strchr(++cptr, '"');
@ -534,8 +534,8 @@ messageAddArguments(message *m, const char *s)
} else
string++;
if(!usefulArg(key)) {
free((char *)key);
if(!usefulArg(kcopy)) {
free(kcopy);
continue;
}
@ -557,18 +557,18 @@ messageAddArguments(message *m, const char *s)
cli_dbgmsg("Can't parse header \"%s\" - if you believe this file contains a virus, submit it to www.clamav.net\n", s);
if(data)
free(data);
free((char *)key);
free(kcopy);
return;
}
*ptr = '\0';
field = cli_realloc((char *)key, strlen(key) + strlen(data) + 2);
field = cli_realloc(kcopy, strlen(kcopy) + strlen(data) + 2);
if(field) {
strcat(field, "=");
strcat(field, data);
} else
free((char *)key);
free(kcopy);
free(data);
} else {
size_t len;
@ -614,7 +614,7 @@ messageGetArgument(const message *m, int arg)
* Find a MIME variable from the header and return a COPY to the value of that
* variable. The caller must free the copy
*/
const char *
char *
messageFindArgument(const message *m, const char *variable)
{
int i;
@ -632,8 +632,8 @@ messageFindArgument(const message *m, const char *variable)
if((ptr == NULL) || (*ptr == '\0'))
continue;
#ifdef CL_DEBUG
cli_dbgmsg("messageFindArgument: compare %d bytes of %s with %s\n",
len, variable, ptr);
cli_dbgmsg("messageFindArgument: compare %lu bytes of %s with %s\n",
(unsigned long)len, variable, ptr);
#endif
if(strncasecmp(ptr, variable, len) == 0) {
ptr = &ptr[len];
@ -1222,7 +1222,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
blobAddData(u, &c, 1);
} else {
#ifdef CL_DEBUG
cli_dbgmsg("uncompress HQX7 at 0x%06x: %d repetitive bytes\n", l, count);
cli_dbgmsg("uncompress HQX7 at 0x%06lu: %d repetitive bytes\n", l, count);
#endif
blobGrow(u, count);
while(--count > 0)
@ -1385,13 +1385,15 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
* Find the filename to decode
*/
if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) {
const char *f;
/*
* TODO: handle multipart yEnc encoded files
*/
t_line = yEncBegin(m);
filename = (char *)lineGetData(t_line->t_line);
f = lineGetData(t_line->t_line);
if((filename = strstr(filename, " name=")) != NULL) {
if((filename = strstr(f, " name=")) != NULL) {
filename = cli_strdup(&filename[6]);
if(filename) {
cli_chomp(filename);
@ -1528,7 +1530,8 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
}
} while((t_line = t_line->t_next) != NULL);
cli_dbgmsg("Exported %u bytes using enctype %d\n", size, enctype);
cli_dbgmsg("Exported %lu bytes using enctype %d\n",
(unsigned long)size, enctype);
/* Verify we have nothing left to flush out */
if(m->base64chars) {
@ -2387,7 +2390,7 @@ messageDedup(message *m)
}
}
cli_dbgmsg("messageDedup reclaimed %u bytes\n", saved);
cli_dbgmsg("messageDedup reclaimed %lu bytes\n", (unsigned long)saved);
m->dedupedThisFar = t1;
}

@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
static char const rcsid[] = "$Id: pdf.c,v 1.60 2007/02/10 14:21:46 njh Exp $";
static char const rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -50,7 +50,7 @@ static char const rcsid[] = "$Id: pdf.c,v 1.60 2007/02/10 14:21:46 njh Exp $";
#include "mbox.h"
#include "pdf.h"
static int flatedecode(const unsigned char *buf, off_t len, int fout, const cli_ctx *ctx);
static int flatedecode(unsigned char *buf, off_t len, int fout, const cli_ctx *ctx);
static int ascii85decode(const char *buf, off_t len, unsigned char *output);
static const char *pdf_nextlinestart(const char *ptr, size_t len);
static const char *pdf_nextobject(const char *ptr, size_t len);
@ -89,7 +89,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
if(buf == MAP_FAILED)
return CL_EMEM;
cli_dbgmsg("cli_pdf: scanning %lu bytes\n", size);
cli_dbgmsg("cli_pdf: scanning %lu bytes\n", (unsigned long)size);
/* Lines are terminated by \r, \n or both */
@ -355,7 +355,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
if(zstat != Z_OK)
rc = CL_EZIP;
} else
cli_writen(fout, (char *)streamstart, streamlen);
cli_writen(fout, (const char *)streamstart, streamlen);
}
free(tmpbuf);
} else if(is_flatedecode) {
@ -364,9 +364,9 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
if(zstat != Z_OK)
rc = CL_EZIP;
} else {
cli_dbgmsg("cli_pdf: writing %u bytes from the stream\n",
streamlen);
cli_writen(fout, (char *)streamstart, streamlen);
cli_dbgmsg("cli_pdf: writing %lu bytes from the stream\n",
(unsigned long)streamlen);
cli_writen(fout, (const char *)streamstart, streamlen);
}
close(fout);
@ -390,7 +390,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
/* flate inflation - returns zlib status, e.g. Z_OK */
static int
flatedecode(const unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
flatedecode(unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
{
int zstat;
off_t nbytes;
@ -402,7 +402,7 @@ flatedecode(const unsigned char *buf, off_t len, int fout, const cli_ctx *ctx)
stream.zalloc = (alloc_func)Z_NULL;
stream.zfree = (free_func)Z_NULL;
stream.opaque = (void *)NULL;
stream.next_in = (unsigned char *)buf;
stream.next_in = (Bytef *)buf;
stream.avail_in = len;
stream.next_out = output;
stream.avail_out = sizeof(output);
@ -540,7 +540,8 @@ ascii85decode(const char *buf, off_t len, unsigned char *output)
len = 0;
break;
} else if(!isspace(byte)) {
cli_warnmsg("ascii85Decode: invalid character 0x%x, len %lu\n", byte & 0xFF, len);
cli_warnmsg("ascii85Decode: invalid character 0x%x, len %lu\n",
byte & 0xFF, (unsigned long)len);
return -1;
}
}

@ -17,6 +17,9 @@
* MA 02110-1301, USA.
*
* $Log: text.c,v $
* Revision 1.25 2007/02/12 20:46:09 njh
* Various tidy
*
* Revision 1.24 2006/09/13 20:53:50 njh
* Added debug
*
@ -82,7 +85,7 @@
*
*/
static char const rcsid[] = "$Id: text.c,v 1.24 2006/09/13 20:53:50 njh Exp $";
static char const rcsid[] = "$Id: text.c,v 1.25 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -349,9 +352,9 @@ addToBlob(const line_t *line, void *arg)
if(line) {
const char *l = lineGetData(line);
blobAddData(b, (unsigned char *)l, strlen(l));
blobAddData(b, (const unsigned char *)l, strlen(l));
}
blobAddData(b, (unsigned char *)"\n", 1);
blobAddData(b, (const unsigned char *)"\n", 1);
}
static void
@ -362,9 +365,9 @@ addToFileblob(const line_t *line, void *arg)
if(line) {
const char *l = lineGetData(line);
fileblobAddData(fb, (unsigned char *)l, strlen(l));
fileblobAddData(fb, (const unsigned char *)l, strlen(l));
}
fileblobAddData(fb, (unsigned char *)"\n", 1);
fileblobAddData(fb, (const unsigned char *)"\n", 1);
}
static void *

@ -20,7 +20,7 @@
* Author: Charles G. Waldman (cgw@pgt.com), Aug 4 1998
* There are many tar files that this code cannot decode.
*/
static char const rcsid[] = "$Id: untar.c,v 1.34 2007/02/10 14:21:46 njh Exp $";
static char const rcsid[] = "$Id: untar.c,v 1.35 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -223,7 +223,10 @@ cli_untar(const char *dir, int desc, unsigned int posix, const struct cl_limits
if(fd < 0) {
cli_errmsg("Can't create temporary file %s: %s\n", fullname, strerror(errno));
cli_dbgmsg("%u %d %d\n", suffixLen, sizeof(fullname), strlen(fullname));
cli_dbgmsg("%lu %lu %lu\n",
(unsigned long)suffixLen,
(unsigned long)sizeof(fullname),
(unsigned long)strlen(fullname));
return CL_ETMPFILE;
}

Loading…
Cancel
Save