~ubuntu-branches/ubuntu/wily/clamav/wily

« back to all changes in this revision

Viewing changes to libclamav/ole2_extract.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2008-09-05 17:25:34 UTC
  • mfrom: (0.35.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080905172534-yi3f8fkye1o7u1r3
* New upstream version (closes: #497662, #497773)
  - lots of new options for clamd.conf
  - fixes CVEs CVE-2008-3912, CVE-2008-3913, CVE-2008-3914, and
    CVE-2008-1389
* No longer supports --unzip option, so typo is gone (closes: #496276)
* Translations:
  - sv (thanks Martin Bagge <brother@bsnet.se>) (closes: #491760)

Show diffs side-by-side

added added

removed removed

Lines of Context:
575
575
                                cli_dbgmsg("OLE2: files limit reached (max: %u)\n", ctx->limits->maxfiles);
576
576
                                return CL_BREAK;
577
577
                        }
578
 
                        if (!limits || !limits->maxfilesize || prop_block[idx].size <= limits->maxfilesize || *scansize == -1 || prop_block[idx].size <= *scansize) {
 
578
                        if (!limits || !limits->maxfilesize || prop_block[idx].size <= limits->maxfilesize || prop_block[idx].size <= *scansize) {
579
579
                                (*file_count)++;
580
580
                                *scansize-=prop_block[idx].size;
581
581
                                if ((ret=handler(fd, hdr, &prop_block[idx], dir, ctx)) != CL_SUCCESS)
625
625
        int32_t current_block, ofd, len, offset;
626
626
        char *name, newname[1024];
627
627
        bitset_t *blk_bitset;
628
 
        uint32_t hash, cnt;
 
628
        char *hash;
 
629
        uint32_t cnt;
629
630
 
630
631
        if (prop->type != 2) {
631
632
                /* Not a file */
640
641
        name = get_property_name2(prop->name, prop->name_size);
641
642
        if (name) cnt = uniq_add(hdr->U, name, strlen(name), &hash);
642
643
        else cnt = uniq_add(hdr->U, NULL, 0, &hash);
643
 
        snprintf(newname, sizeof(newname), "%s/%u_%u", dir, hash, cnt);
 
644
        snprintf(newname, sizeof(newname), "%s/%s_%u", dir, hash, cnt);
644
645
        newname[sizeof(newname)-1]='\0';
645
646
        cli_dbgmsg("OLE2 [handler_writefile]: Dumping '%s' to '%s'\n", name ? name : "<empty>", newname);
646
647
        if (name) free(name);
781
782
  buff = (unsigned char *) cli_malloc(1 << hdr->log2_big_block_size);
782
783
  if (!buff) {
783
784
    close(ofd);
784
 
    unlink(tempfile);
 
785
    cli_unlink(tempfile);
785
786
    free(tempfile);
786
787
    return CL_EMEM;
787
788
  }
792
793
    cli_errmsg("OLE2: OTF handler init bitset failed\n");
793
794
    free(buff);
794
795
    close(ofd);
795
 
    unlink(tempfile);
 
796
    if (cli_unlink(tempfile)) {
 
797
        free(tempfile);
 
798
        return CL_EIO;
 
799
    }
796
800
    free(tempfile);
797
801
    return CL_BREAK;
798
802
  }
823
827
        close(ofd);
824
828
        free(buff);
825
829
        cli_bitset_free(blk_bitset);
826
 
        unlink(tempfile);
 
830
        if (cli_unlink(tempfile)) {
 
831
          free(tempfile);
 
832
          return CL_EIO;
 
833
        }
827
834
        free(tempfile);
828
835
        return CL_BREAK;
829
836
      }
840
847
        close(ofd);
841
848
        free(buff);
842
849
        cli_bitset_free(blk_bitset);
843
 
        unlink(tempfile);
 
850
        if (cli_unlink(tempfile)) {
 
851
          free(tempfile);
 
852
          return CL_EIO;
 
853
        }
844
854
        free(tempfile);
845
855
        return CL_EIO;
846
856
      }
855
865
  close(ofd);
856
866
  free(buff);
857
867
  cli_bitset_free(blk_bitset);
858
 
  if(!cli_leavetemps_flag)
859
 
    unlink(tempfile);
 
868
  if(!cli_leavetemps_flag) {
 
869
    if (cli_unlink(tempfile)) {
 
870
      free(tempfile);
 
871
      return CL_EIO;
 
872
    }
 
873
  }
860
874
  free(tempfile);
861
875
  return ret==CL_VIRUS ? CL_VIRUS : CL_SUCCESS;
862
876
 
1063
1077
        if(hdr.bitset)
1064
1078
            cli_bitset_free(hdr.bitset);
1065
1079
 
1066
 
        return ret;
 
1080
        return ret == CL_BREAK ? CL_CLEAN : ret;
1067
1081
}