Browse code

bb11560 - make cdb signatures also operate on central directory file names because they can differ from the file names in the local headers.

Steven Morgan authored on 2016/05/10 02:53:27
Showing 1 changed files
... ...
@@ -620,6 +620,7 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
620 620
   char name[256];
621 621
   int last = 0;
622 622
   const uint8_t *ch;
623
+  int virus_found = 0;
623 624
 
624 625
   if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) {
625 626
       if(ch) fmap_unneed_ptr(map, ch, SIZEOF_CH);
... ...
@@ -636,7 +637,7 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
636 636
   }
637 637
 
638 638
   name[0]='\0';
639
-  if((cli_debug_flag && !last) || requests) {
639
+  if(!last) {
640 640
       unsigned int size = (CH_flen>=sizeof(name))?sizeof(name)-1:CH_flen;
641 641
       const char *src = fmap_need_off_once(map, coff, size);
642 642
       if(src) {
... ...
@@ -647,6 +648,9 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
647 647
   }
648 648
   coff+=CH_flen;
649 649
 
650
+  if(cli_matchmeta(ctx, name, CH_csize, CH_usize, (CH_flags & F_ENCR)!=0, fc, CH_crc32, NULL) == CL_VIRUS)
651
+    virus_found = 1;
652
+
650 653
   if(zsize-coff<=CH_elen && !last) {
651 654
     cli_dbgmsg("cli_unzip: ch - extra out of file\n");
652 655
     last=1;
... ...
@@ -682,6 +686,8 @@ static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned in
682 682
       }
683 683
   }
684 684
 
685
+  if (virus_found == 1)
686
+      *ret = CL_VIRUS;
685 687
   fmap_unneed_ptr(map, ch, SIZEOF_CH);
686 688
   return (last?0:coff);
687 689
 }