diff --git a/ChangeLog b/ChangeLog index 7474182d1..c4d6099d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 4 15:35:16 CET 2010 (tk) +--------------------------------- + * libclamav: fix error reporting for BinHex files (bb#1685) + Wed Dec 30 00:19:21 CET 2009 (tk) --------------------------------- * libclamav: add support for FileSize, EntryPoint and NumberOfSections in diff --git a/libclamav/binhex.c b/libclamav/binhex.c index 705f6834e..30d010803 100644 --- a/libclamav/binhex.c +++ b/libclamav/binhex.c @@ -120,6 +120,7 @@ cli_binhex(const char *dir, fmap_t *map) long bytesleft; message *m; fileblob *fb; + text *t_line; size = (size_t)map->len; @@ -179,12 +180,20 @@ cli_binhex(const char *dir, fmap_t *map) if(line) free(line); - if(binhexBegin(m) == NULL) { + if((t_line = binhexBegin(m)) == NULL) { messageDestroy(m); cli_dbgmsg("No binhex line found\n"); return CL_EFORMAT; } + while(((t_line = t_line->t_next) != NULL) && (t_line->t_line == NULL)); + + if(!t_line) { + messageDestroy(m); + cli_dbgmsg("No binhex data to parse\n"); + return CL_EFORMAT; + } + /* similar to binhexMessage */ messageSetEncoding(m, "x-binhex"); @@ -199,5 +208,6 @@ cli_binhex(const char *dir, fmap_t *map) if(fb) return CL_CLEAN; /* a lie - but it gets things going */ /* return CL_EIO; */ /* probably CL_EMEM, but we can't tell at this layer */ - return CL_EMEM; + /* TK: CL_EMEM is too generic here and should not be reported for parsing errors */ + return CL_EFORMAT; } diff --git a/libclamav/message.c b/libclamav/message.c index a9366a847..659d37449 100644 --- a/libclamav/message.c +++ b/libclamav/message.c @@ -1212,6 +1212,12 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy (t_line->t_line == NULL)) ; + if(!t_line) { + cli_warnmsg("No binhex data to parse\n"); + (*destroy)(ret); + return NULL; + } + tmp = textToBlob(t_line, NULL, ((m->numberOfEncTypes == 1) && (m->encodingTypes[0] == BINHEX)) ? destroy_text : 0);