Don't loop if binhex runs out of memory

git-svn: trunk@2055
remotes/push_mirror/metadata
Nigel Horne 19 years ago
parent 343316aba2
commit 826864d60c
  1. 6
      clamav-devel/ChangeLog
  2. 9
      clamav-devel/libclamav/binhex.c
  3. 11
      clamav-devel/libclamav/blob.c
  4. 2
      clamav-devel/libclamav/blob.h
  5. 3
      clamav-devel/libclamav/message.c
  6. 13
      clamav-devel/libclamav/text.c

@ -1,3 +1,9 @@
Sat Jul 1 04:49:32 BST 2006 (njh)
----------------------------------
* libclamav: Large binhex files were not being handled gracefully. Tidied
the handling code. Note that large binhex are not
currently decoded
Thu Jun 29 19:42:01 CEST 2006 (acab)
* libclamav: Revert old UPX code due to bugs
Add algorithmic detection of Win32.Kriz

@ -18,6 +18,9 @@
*
* Change History:
* $Log: binhex.c,v $
* Revision 1.20 2006/07/01 03:47:50 njh
* Don't loop if binhex runs out of memory
*
* Revision 1.19 2006/05/19 11:02:12 njh
* Just include mbox.h
*
@ -73,7 +76,7 @@
* First draft of binhex.c
*
*/
static char const rcsid[] = "$Id: binhex.c,v 1.19 2006/05/19 11:02:12 njh Exp $";
static char const rcsid[] = "$Id: binhex.c,v 1.20 2006/07/01 03:47:50 njh Exp $";
#include "clamav.h"
@ -188,6 +191,8 @@ cli_binhex(const char *dir, int desc)
cli_errmsg("No binhex line found\n");
return CL_EFORMAT;
}
/* similar to binhexMessage */
messageSetEncoding(m, "x-binhex");
fb = messageToFileblob(m, dir);
@ -200,6 +205,6 @@ cli_binhex(const char *dir, int desc)
if(fb)
return CL_CLEAN; /* a lie - but it gets things going */
return CL_EOPEN;
return CL_EIO;
#endif
}

@ -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.49 2006/06/08 10:13:12 njh Exp $";
static char const rcsid[] = "$Id: blob.c,v 1.50 2006/07/01 03:47:50 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -297,14 +297,17 @@ blobcmp(const blob *b1, const blob *b2)
return memcmp(blobGetData(b1), blobGetData(b2), s1);
}
void
/*
* Return clamav return code
*/
int
blobGrow(blob *b, size_t len)
{
assert(b != NULL);
assert(b->magic == BLOBCLASS);
if(len == 0)
return;
return CL_SUCCESS;
if(b->isClosed) {
/*
@ -329,6 +332,8 @@ blobGrow(blob *b, size_t len)
b->data = ptr;
}
}
return (b->data) ? CL_SUCCESS : CL_EMEM;
}
fileblob *

@ -44,7 +44,7 @@ unsigned char *blobGetData(const blob *b);
unsigned long blobGetDataSize(const blob *b);
void blobClose(blob *b);
int blobcmp(const blob *b1, const blob *b2);
void blobGrow(blob *b, size_t len);
int blobGrow(blob *b, size_t len);
/*
* Like a blob, but associated with a file

@ -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.175 2006/06/20 16:54:31 tkojm Exp $";
static char const rcsid[] = "$Id: message.c,v 1.176 2006/07/01 03:47:50 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -1053,6 +1053,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
/* 70-7f */ 0x3d,0x3e,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
cli_dbgmsg("messageExport: decode binhex\n");
/*
* Decode BinHex4. First create a temporary blob which contains
* the encoded message. Then decode that blob to the target

@ -17,6 +17,9 @@
* MA 02110-1301, USA.
*
* $Log: text.c,v $
* Revision 1.20 2006/07/01 03:47:50 njh
* Don't loop if binhex runs out of memory
*
* Revision 1.19 2006/05/19 11:02:12 njh
* Just include mbox.h
*
@ -67,7 +70,7 @@
*
*/
static char const rcsid[] = "$Id: text.c,v 1.19 2006/05/19 11:02:12 njh Exp $";
static char const rcsid[] = "$Id: text.c,v 1.20 2006/07/01 03:47:50 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -233,6 +236,7 @@ blob *
textToBlob(const text *t, blob *b)
{
size_t s;
blob *bin;
if(t == NULL)
return NULL;
@ -251,7 +255,12 @@ textToBlob(const text *t, blob *b)
return NULL;
}
blobGrow(b, s);
bin = b;
if(blobGrow(b, s) != CL_SUCCESS) {
if(bin == NULL)
blobDestroy(b);
return NULL;
}
(void)textIterate(t, addToBlob, b);

Loading…
Cancel
Save