Browse code

Included patch from Thomas Lamy: > - a fix to my own fix (*ret was declared const -> gcc warning) > - antoher fix to my own code (double fclose() on malformed zip archive) > - global to local fix for unrarlib.c (BOOL FileFound).

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@46 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2003/09/17 01:09:12
Showing 3 changed files
... ...
@@ -1,3 +1,10 @@
1
+Tue Sep 16 18:06:47 CEST 2003 (tk)
2
+----------------------------------
3
+  * libclamav: included patch from Thomas Lamy:
4
+       > - a fix to my own fix (*ret was declared const -> gcc warning)
5
+       > - antoher fix to my own code (double fclose() on malformed zip archive)
6
+       > - global to local fix for unrarlib.c (BOOL FileFound).
7
+
1 8
 Mon Sep 15 14:09:50 BST 2003
2 9
 ----------------------------
3 10
   * libclamav/mbox.c: Fixed potential buffer overrun files with long names
... ...
@@ -331,6 +331,7 @@ int cli_scanzip(int desc, char **virname, long int *scanned, const struct cl_nod
331 331
 	     */
332 332
 	    cli_dbgmsg("Zip -> Malformed Zip, scanning stopped.\n");
333 333
 	    fclose(tmp);
334
+	    tmp = NULL;
334 335
 	    *virname = "Malformed Zip";
335 336
 	    ret = CL_VIRUS;
336 337
 	    break;
... ...
@@ -615,6 +616,10 @@ int cli_magic_scandesc(int desc, char **virname, long int *scanned, const struct
615 615
 	lseek(desc, 0, SEEK_SET);
616 616
 
617 617
 
618
+	if (bread != MAGIC_BUFFER_SIZE) {
619
+	    /* short read: No need to do magic */
620
+	    return ret;
621
+	}
618 622
 #ifdef CL_THREAD_SAFE
619 623
 	/* this check protects against recursive deadlock */
620 624
 	if(SCAN_ARCHIVE && !cli_scanrar_inuse && !strncmp(magic, RAR_MAGIC_STR, strlen(RAR_MAGIC_STR))) {
... ...
@@ -316,10 +316,8 @@ char Password[255];                         /* password to decrypt files    */
316 316
 unsigned char *temp_output_buffer;          /* extract files to this pointer*/
317 317
 unsigned long *temp_output_buffer_offset;   /* size of temp. extract buffer */
318 318
 
319
-BOOL FileFound;                             /* TRUE=use current extracted   */
320
-                                            /* data FALSE=throw data away,  */
321
-                                            /* wrong file                   */
322 319
 int MainHeadSize;
320
+
323 321
 long CurBlockPos,NextBlockPos;
324 322
 
325 323
 unsigned long CurUnpRead, CurUnpWrite;
... ...
@@ -349,7 +347,7 @@ int IsArchive(void);
349 349
 int ReadBlock(int BlockType);
350 350
 unsigned int UnpRead(unsigned char *Addr,unsigned int Count);
351 351
 void UnpInitData(void);
352
-void Unpack(unsigned char *UnpAddr);
352
+void Unpack(unsigned char *UnpAddr, BOOL FileFound);
353 353
 UBYTE DecodeAudio(int Delta);
354 354
 static void DecodeNumber(struct Decode *Dec);
355 355
 void UpdKeys(UBYTE *Buf);
... ...
@@ -916,7 +914,9 @@ int IsArchive(void)
916 916
 BOOL ExtrFile(int desc)
917 917
 {
918 918
   BOOL ReturnCode=TRUE;
919
-  FileFound=FALSE;                          /* no file found by default     */
919
+  BOOL FileFound=FALSE;                     /* TRUE=use current extracted   */
920
+                                            /* data FALSE=throw data away,  */
921
+                                            /* wrong file                   */
920 922
   int newdesc;
921 923
 
922 924
 #ifdef  _USE_MEMORY_TO_MEMORY_DECOMPRESSION
... ...
@@ -1036,7 +1036,7 @@ BOOL ExtrFile(int desc)
1036 1036
         UnstoreFile();
1037 1037
       } else
1038 1038
       {
1039
-        Unpack(UnpMemory);
1039
+        Unpack(UnpMemory, FileFound);
1040 1040
       }
1041 1041
 
1042 1042
 
... ...
@@ -1349,7 +1349,7 @@ static struct MultDecode *MDPtr[4]={&MD[0],&MD[1],&MD[2],&MD[3]};
1349 1349
 int UnpAudioBlock,UnpChannels,CurChannel,ChannelDelta;
1350 1350
 
1351 1351
 
1352
-void Unpack(unsigned char *UnpAddr)
1352
+void Unpack(unsigned char *UnpAddr, BOOL FileFound)
1353 1353
 /* *** 38.3% of all CPU time is spent within this function!!!               */
1354 1354
 {
1355 1355
   static unsigned char LDecode[]={0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,