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

« back to all changes in this revision

Viewing changes to libclamav/matcher.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-05-05 14:14:58 UTC
  • mfrom: (0.47.16)
  • Revision ID: package-import@ubuntu.com-20150505141458-mbkr5jjfu3j9gdvd
Tags: 0.98.7+dfsg-0ubuntu1
* Updated to 0.98.7 to fix multiple issues
  - CVE-2015-2170
  - CVE-2015-2221
  - CVE-2015-2222
  - CVE-2015-2305
  - CVE-2015-2668
* Refreshed patches for 0.98.7:
  - d/p/0005-libclamav-use-libmspack.patch
  - d/p/0007-fix-ssize_t-size_t-off_t-printf-modifier.patch
  - d/p/0008-hardcode-LLVM-linker-flag-because-llvm-config-return.patch
  - d/p/0015-llvm-don-t-use-system-libs.patch
* Removed upstreamed patches:
  - d/p/0012-remove-AC_CONFIG_SRCDIR-llvm-configure-from-libclama.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
                              struct cli_ac_result **acres,
100
100
                              fmap_t *map,
101
101
                              struct cli_bm_off *offdata,
102
 
                              uint32_t *viroffset,
103
102
                              cli_ctx *ctx)
104
103
{
105
104
    int ret;
140
139
            /* Don't use prefiltering for BM offset mode, since BM keeps tracks
141
140
             * of offsets itself, and doesn't work if we skip chunks of input
142
141
             * data */
143
 
            ret = cli_bm_scanbuff(orig_buffer, orig_length, virname, NULL, root, orig_offset, tinfo, offdata, viroffset);
 
142
            ret = cli_bm_scanbuff(orig_buffer, orig_length, virname, NULL, root, orig_offset, tinfo, offdata, ctx);
144
143
        } else {
145
 
            ret = cli_bm_scanbuff(buffer, length, virname, NULL, root, offset, tinfo, offdata, viroffset);
 
144
            ret = cli_bm_scanbuff(buffer, length, virname, NULL, root, offset, tinfo, offdata, ctx);
146
145
        }
147
 
        if (ret == CL_VIRUS) {
148
 
            if (ctx) {
 
146
        if (ret != CL_CLEAN) {
 
147
            if (ret != CL_VIRUS)
 
148
                return ret;
 
149
 
 
150
            /* else (ret == CL_VIRUS) */
 
151
            if (SCAN_ALL)
 
152
                viruses_found = 1;
 
153
            else {
149
154
                cli_append_virus(ctx, *virname);
150
 
                if (SCAN_ALL)
151
 
                    viruses_found++;
152
 
                else
153
 
                    return ret;
 
155
                return ret;
154
156
            }
155
157
        }
156
158
    }
198
200
        if(!acdata && (ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, troot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN)))
199
201
            return ret;
200
202
 
201
 
        ret = matcher_run(troot, buffer, length, &virname, acdata ? (acdata[0]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, NULL, ctx);
 
203
        ret = matcher_run(troot, buffer, length, &virname, acdata ? (acdata[0]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, ctx);
202
204
 
203
205
        if(!acdata)
204
206
            cli_ac_freedata(&mdata);
218
220
    if(!acdata && (ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN)))
219
221
        return ret;
220
222
 
221
 
    ret = matcher_run(groot, buffer, length, &virname, acdata ? (acdata[1]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, NULL, ctx);
 
223
    ret = matcher_run(groot, buffer, length, &virname, acdata ? (acdata[1]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, ctx);
222
224
 
223
225
    if(!acdata)
224
226
        cli_ac_freedata(&mdata);
732
734
    fmap_t *map = *ctx->fmap;
733
735
    struct cli_matcher *hdb, *fp;
734
736
    const char *virname = NULL;
735
 
    uint32_t viroffset = 0;
736
737
    uint32_t viruses_found = 0;
737
738
    void *md5ctx, *sha1ctx, *sha256ctx;
738
739
 
878
879
 
879
880
        if(troot) {
880
881
                virname = NULL;
881
 
                viroffset = 0;
882
 
                ret = matcher_run(troot, buff, bytes, &virname, &tdata, offset, &info, ftype, ftoffset, acmode, acres, map, bm_offmode ? &toff : NULL, &viroffset, ctx);
 
882
                ret = matcher_run(troot, buff, bytes, &virname, &tdata, offset, &info, ftype, ftoffset, acmode, acres, map, bm_offmode ? &toff : NULL, ctx);
883
883
 
884
884
            if (virname) {
885
885
                /* virname already appended by matcher_run */
906
906
 
907
907
        if(!ftonly) {
908
908
            virname = NULL;
909
 
            viroffset = 0;
910
 
            ret = matcher_run(groot, buff, bytes, &virname, &gdata, offset, &info, ftype, ftoffset, acmode, acres, map, NULL, &viroffset, ctx);
 
909
            ret = matcher_run(groot, buff, bytes, &virname, &gdata, offset, &info, ftype, ftoffset, acmode, acres, map, NULL, ctx);
911
910
 
912
911
            if (virname) {
913
912
                /* virname already appended by matcher_run */
934
933
                    type = ret;
935
934
            }
936
935
 
937
 
            if(hdb) {
 
936
            /* if (bytes <= (maxpatlen * (offset!=0))), it means the last window finished the file hashing *
 
937
             *   since the last window is responsible for adding intersection between windows (maxpatlen)  */
 
938
            if(hdb && (bytes > (maxpatlen * (offset!=0)))) {
938
939
                const void *data = buff + maxpatlen * (offset!=0);
939
940
                uint32_t data_len = bytes - maxpatlen * (offset!=0);
940
941
 
947
948
            }
948
949
        }
949
950
 
950
 
        if(SCAN_ALL && viroffset) {
951
 
            offset = viroffset;
952
 
            continue;
953
 
        }
954
 
 
955
951
        if(bytes < SCANBUFF)
956
952
            break;
957
953