From b5f8af0dc608a3de408a558732b538ec1678c7b3 Mon Sep 17 00:00:00 2001 From: Tomasz Kojm Date: Mon, 15 Mar 2004 16:01:55 +0000 Subject: [PATCH] fixed segfault with Bagle rars git-svn: trunk@401 --- clamav-devel/ChangeLog | 4 ++++ clamav-devel/libclamav/scanners.c | 6 ++++-- clamav-devel/libclamav/unrarlib.c | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index 1b23612bd..2ef04bcba 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Mon Mar 15 17:05:01 CET 2004 (tk) +--------------------------------- + * libclamav: unrarlib: fixed segfault with some Bagle's RAR archives + Sun Mar 14 21:48:25 CET 2004 (tk) --------------------------------- * etc/clamav.conf: ScanOLE2 enabled by default diff --git a/clamav-devel/libclamav/scanners.c b/clamav-devel/libclamav/scanners.c index c51a9d07e..7139a996e 100644 --- a/clamav-devel/libclamav/scanners.c +++ b/clamav-devel/libclamav/scanners.c @@ -173,7 +173,7 @@ static void cli_unlock_mutex(void *mtx) static int cli_scanrar(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, int *reclev) { FILE *tmp = NULL; - int files = 0, fd, ret = CL_CLEAN; + int files = 0, fd, ret = CL_CLEAN, afiles; ArchiveList_struct *rarlist = NULL; ArchiveList_struct *rarlist_head = NULL; char *rar_data_ptr; @@ -188,7 +188,7 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const cli_scanrar_inuse = 1; #endif - if(!urarlib_list(desc, (ArchiveList_struct *) &rarlist)) { + if(! (afiles = urarlib_list(desc, (ArchiveList_struct *) &rarlist))) { #ifdef CL_THREAD_SAFE pthread_mutex_unlock(&cli_scanrar_mutex); cli_scanrar_inuse = 0; @@ -196,6 +196,8 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const return CL_ERAR; } + cli_dbgmsg("Rar -> Number of archived files: %d\n", afiles); + rarlist_head = rarlist; while(rarlist) { diff --git a/clamav-devel/libclamav/unrarlib.c b/clamav-devel/libclamav/unrarlib.c index b9ef5a5f2..70551c39c 100644 --- a/clamav-devel/libclamav/unrarlib.c +++ b/clamav-devel/libclamav/unrarlib.c @@ -533,11 +533,13 @@ int urarlib_list(int desc, ArchiveList_struct *list) if ((ReadBlockResult = ReadBlock(FILE_HEAD | READSUBBLOCK)) <= 0) /* read name of the next */ { /* file within the RAR archive */ cli_dbgmsg("Couldn't read next filename from archive (I/O error): %d\n", ReadBlockResult); + NoOfFilesInArchive = 0; break; /* error, file not found in */ } /* archive or I/O error */ if (BlockHead.HeadType==SUB_HEAD) { debug_log("Sorry, sub-headers not supported."); + NoOfFilesInArchive = 0; break; /* error => exit */ }