Browse code

modified cli_map_scan and cli_map_scandesc to take a cli_file_t modified all respective calls to the above change

Kevin Lin authored on 2014/01/24 07:03:47
Showing 6 changed files
... ...
@@ -157,7 +157,7 @@ int cli_scancpio_old(cli_ctx *ctx)
157 157
 	    if(ret == CL_EMAXFILES) {
158 158
 		return ret;
159 159
 	    } else if(ret == CL_SUCCESS) {
160
-		ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx);
160
+		ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY);
161 161
 		if(ret == CL_VIRUS)
162 162
 		    return ret;
163 163
 	    }
... ...
@@ -234,7 +234,7 @@ int cli_scancpio_odc(cli_ctx *ctx)
234 234
 	if(ret == CL_EMAXFILES) {
235 235
 	    return ret;
236 236
 	} else if(ret == CL_SUCCESS) {
237
-	    ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx);
237
+	    ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY);
238 238
 	    if(ret == CL_VIRUS)
239 239
 		return ret;
240 240
 	}
... ...
@@ -313,7 +313,7 @@ int cli_scancpio_newc(cli_ctx *ctx, int crc)
313 313
 	if(ret == CL_EMAXFILES) {
314 314
 	    return ret;
315 315
 	} else if(ret == CL_SUCCESS) {
316
-	    ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx);
316
+	    ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY);
317 317
 	    if(ret == CL_VIRUS)
318 318
 		return ret;
319 319
 	}
... ...
@@ -180,7 +180,7 @@ int cli_scandmg(cli_ctx *ctx)
180 180
     }
181 181
 
182 182
     /* scan XML with cli_map_scandesc */
183
-    ret = cli_map_scan(*ctx->fmap, (off_t)hdr.xmlOffset, (size_t)hdr.xmlLength, ctx);
183
+    ret = cli_map_scan(*ctx->fmap, (off_t)hdr.xmlOffset, (size_t)hdr.xmlLength, ctx, CL_TYPE_ANY);
184 184
     if (ret != CL_CLEAN) {
185 185
         cli_dbgmsg("cli_scandmg: retcode from scanning TOC xml: %s\n", cl_strerror(ret));
186 186
         if (!ctx->engine->keeptmp)
... ...
@@ -553,7 +553,7 @@ int cli_scanmacho_unibin(cli_ctx *ctx)
553 553
 	cli_dbgmsg("UNIBIN: Binary %u of %u\n", i + 1, fat_header.nfats);
554 554
 	cli_dbgmsg("UNIBIN: File offset: %u\n", fat_arch.offset);
555 555
 	cli_dbgmsg("UNIBIN: File size: %u\n", fat_arch.size);
556
-	ret = cli_map_scan(map, fat_arch.offset, fat_arch.size, ctx);
556
+	ret = cli_map_scan(map, fat_arch.offset, fat_arch.size, ctx, CL_TYPE_ANY);
557 557
 	if(ret == CL_VIRUS)
558 558
 	    break;
559 559
     }
... ...
@@ -554,7 +554,7 @@ char *cli_gentemp(const char *dir);
554 554
 int cli_gentempfd(const char *dir, char **name, int *fd);
555 555
 unsigned int cli_rndnum(unsigned int max);
556 556
 int cli_filecopy(const char *src, const char *dest);
557
-int cli_mapscan(fmap_t *map, off_t offset, size_t size, cli_ctx *ctx);
557
+int cli_mapscan(fmap_t *map, off_t offset, size_t size, cli_ctx *ctx, cli_file_t type);
558 558
 bitset_t *cli_bitset_init(void);
559 559
 void cli_bitset_free(bitset_t *bs);
560 560
 int cli_bitset_set(bitset_t *bs, unsigned long bit_offset);
... ...
@@ -2979,7 +2979,7 @@ int cl_scandesc(int desc, const char **virname, unsigned long int *scanned, cons
2979 2979
 }
2980 2980
 
2981 2981
 /* For map scans that may be forced to disk */
2982
-int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
2982
+int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, cli_file_t type)
2983 2983
 {
2984 2984
     off_t old_off = map->nested_offset;
2985 2985
     size_t old_len = map->len;
... ...
@@ -3035,7 +3035,7 @@ int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
3035 3035
         }
3036 3036
 
3037 3037
         /* scan the temp file */
3038
-        ret = cli_base_scandesc(fd, ctx, CL_TYPE_ANY);
3038
+        ret = cli_base_scandesc(fd, ctx, type);
3039 3039
 
3040 3040
         /* remove the temp file, if needed */
3041 3041
         if (fd > -1) {
... ...
@@ -3051,13 +3051,13 @@ int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
3051 3051
     }
3052 3052
     else {
3053 3053
         /* Not forced to disk, use nested map */
3054
-        ret = cli_map_scandesc(map, offset, length, ctx);
3054
+        ret = cli_map_scandesc(map, offset, length, ctx, type);
3055 3055
     }
3056 3056
     return ret;
3057 3057
 }
3058 3058
 
3059 3059
 /* For map scans that are not forced to disk */
3060
-int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
3060
+int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, cli_file_t type)
3061 3061
 {
3062 3062
     off_t old_off = map->nested_offset;
3063 3063
     size_t old_len = map->len;
... ...
@@ -3091,7 +3091,7 @@ int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
3091 3091
     map->len = length;
3092 3092
     map->real_len = map->nested_offset + length;
3093 3093
     if (CLI_ISCONTAINED(old_off, old_len, map->nested_offset, map->len)) {
3094
-	ret = magic_scandesc(ctx, CL_TYPE_ANY);
3094
+	ret = magic_scandesc(ctx, type);
3095 3095
     } else {
3096 3096
 	long long len1, len2;
3097 3097
 	len1 = old_off + old_len;
... ...
@@ -3114,7 +3114,7 @@ int cli_mem_scandesc(const void *buffer, size_t length, cli_ctx *ctx)
3114 3114
     if (!map) {
3115 3115
 	return CL_EMAP;
3116 3116
     }
3117
-    ret = cli_map_scan(map, 0, length, ctx);
3117
+    ret = cli_map_scan(map, 0, length, ctx, CL_TYPE_ANY);
3118 3118
     cl_fmap_close(map);
3119 3119
     return ret;
3120 3120
 }
... ...
@@ -3163,7 +3163,7 @@ static int scan_common(int desc, cl_fmap_t *map, const char **virname, unsigned
3163 3163
 #endif
3164 3164
 
3165 3165
     cli_logg_setup(&ctx);
3166
-    rc = map ? cli_map_scandesc(map, 0, map->len, &ctx) : cli_magic_scandesc(desc, &ctx);
3166
+    rc = map ? cli_map_scandesc(map, 0, map->len, &ctx, CL_TYPE_ANY) : cli_magic_scandesc(desc, &ctx);
3167 3167
 
3168 3168
     if (ctx.options & CL_SCAN_ALLMATCHES) {
3169 3169
 	*virname = (char *)ctx.virname; /* temp hack for scanall mode until api augmentation */
... ...
@@ -28,8 +28,8 @@
28 28
 int cli_magic_scandesc(int desc, cli_ctx *ctx);
29 29
 int cli_partition_scandesc(int desc, cli_ctx *ctx);
30 30
 int cli_magic_scandesc_type(cli_ctx *ctx, cli_file_t type);
31
-int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx);
32
-int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx);
31
+int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, cli_file_t type);
32
+int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, cli_file_t type);
33 33
 int cli_mem_scandesc(const void *buffer, size_t length, cli_ctx *ctx);
34 34
 int cli_found_possibly_unwanted(cli_ctx* ctx);
35 35