[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

Török Edvin edwin at clamav.net
Sun Apr 4 01:04:10 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 1a486dca3bebdb6a326d5f23932977a63362c72f
Author: Török Edvin <edwin at clamav.net>
Date:   Fri Sep 4 12:09:17 2009 +0300

    Add hidden ctx param to APIcalls.

diff --git a/clambc/bcrun.c b/clambc/bcrun.c
index 954d5ee..d382b6f 100644
--- a/clambc/bcrun.c
+++ b/clambc/bcrun.c
@@ -60,14 +60,14 @@ int main(int argc, char *argv[])
 	fprintf(stderr, "ERROR: Can't parse command line options\n");
 	exit(1);
     }
-    if(optget(opts, "help")->enabled || !opts->filename) {
+    if(optget(opts, "version")->enabled) {
+	printf("Clam AntiVirus Bytecode Testing Tool %s\n", get_version());
 	optfree(opts);
-	help();
 	exit(0);
     }
-    if(optget(opts, "version")->enabled) {
-	printf("Clam AntiVirus Bytecode Testing Tool %s\n", get_version());
+    if(optget(opts, "help")->enabled || !opts->filename) {
 	optfree(opts);
+	help();
 	exit(0);
     }
     f = fopen(opts->filename[0], "r");
@@ -97,11 +97,16 @@ int main(int argc, char *argv[])
 
     if (dbgargc > 1)
 	cli_bytecode_debug(dbgargc, opts->filename);
-    rc = cli_bytecode_init(&bcs);
-    if (rc != CL_SUCCESS) {
-	fprintf(stderr,"Unable to init bytecode engine: %s\n", cl_strerror(rc));
-	optfree(opts);
-	exit(4);
+
+    if (optget(opts, "force-interpreter")->enabled) {
+	bcs.engine = NULL;
+    } else {
+	rc = cli_bytecode_init(&bcs);
+	if (rc != CL_SUCCESS) {
+	    fprintf(stderr,"Unable to init bytecode engine: %s\n", cl_strerror(rc));
+	    optfree(opts);
+	    exit(4);
+	}
     }
 
     bcs.all_bcs = bc;
diff --git a/libclamav/bytecode.h b/libclamav/bytecode.h
index 5f4b231..7e9f94d 100644
--- a/libclamav/bytecode.h
+++ b/libclamav/bytecode.h
@@ -75,4 +75,5 @@ int cli_bytecode_run(const struct cli_all_bc *bcs, const struct cli_bc *bc, stru
 void cli_bytecode_destroy(struct cli_bc *bc);
 int cli_bytecode_done(struct cli_all_bc *allbc);
 
+
 #endif
diff --git a/libclamav/bytecode_api.h b/libclamav/bytecode_api.h
index ed7338f..3028a2c 100644
--- a/libclamav/bytecode_api.h
+++ b/libclamav/bytecode_api.h
@@ -1,6 +1,34 @@
+/*
+ *  ClamAV bytecode API.
+ *
+ *  Copyright (C) 2009 Sourcefire, Inc.
+ *
+ *  Authors: Török Edvin
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA 02110-1301, USA.
+ */
+
+struct lsig_match {
+    uint32_t evalcnt;
+    uint64_t evalids;
+    uint16_t filetype;
+};
+
 struct foo {
     struct foo *nxt;
 };
 
-int32_t cli_bcapi_test0(struct foo*, uint32_t);
-int32_t cli_bcapi_test1(int32_t, int32_t);
+int32_t test0(struct foo*, uint32_t);
+int32_t test1(int32_t, int32_t);
diff --git a/libclamav/bytecode_api_decl.c b/libclamav/bytecode_api_decl.c
index c034a48..f187b18 100644
--- a/libclamav/bytecode_api_decl.c
+++ b/libclamav/bytecode_api_decl.c
@@ -23,6 +23,9 @@
 #include "type_desc.h"
 #include "bytecode_api.h"
 
+uint32_t cli_bcapi_test0(struct cli_bc_ctx *ctx, struct foo*, uint32_t);
+uint32_t cli_bcapi_test1(struct cli_bc_ctx *ctx, uint32_t, uint32_t);
+
 static uint16_t cli_tmp0[]={32, 70, 32};
 static uint16_t cli_tmp1[]={71};
 static uint16_t cli_tmp2[]={70};
@@ -38,8 +41,8 @@ const struct cli_bc_type cli_apicall_types[]={
 const unsigned cli_apicall_maxtypes=sizeof(cli_apicall_types)/sizeof(cli_apicall_types[0]);
 const struct cli_apicall cli_apicalls[]={
 /* Bytecode APIcalls BEGIN */
-	{"cli_bcapi_test0", 0, 0, 1},
-	{"cli_bcapi_test1", 3, 0, 0}
+	{"test0", 0, 0, 1},
+	{"test1", 3, 0, 0}
 /* Bytecode APIcalls END */
 };
 const cli_apicall_int2 cli_apicalls0[] = {
diff --git a/libclamav/bytecode_vm.c b/libclamav/bytecode_vm.c
index 8e031d2..801904d 100644
--- a/libclamav/bytecode_vm.c
+++ b/libclamav/bytecode_vm.c
@@ -576,7 +576,7 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct
 			int32_t a, b, r;
 			READ32(a, inst->u.ops.ops[0]);
 			READ32(b, inst->u.ops.ops[1]);
-			res = cli_apicalls0[api->idx](a, b);
+			res = cli_apicalls0[api->idx](ctx, a, b);
 			break;
 		    }
 		    case 1: {
diff --git a/libclamav/type_desc.h b/libclamav/type_desc.h
index fa8c7ef..b769701 100644
--- a/libclamav/type_desc.h
+++ b/libclamav/type_desc.h
@@ -22,6 +22,8 @@
 #ifndef TYPE_DESC_H
 #define TYPE_DESC_H
 
+struct cli_bc_ctx;
+
 enum derived_t {
   DFunctionType,
   DPointerType,
@@ -38,8 +40,8 @@ struct cli_bc_type {
     unsigned align;
 };
 
-typedef int32_t (*cli_apicall_int2)(int32_t, int32_t);
-typedef int32_t (*cli_apicall_pointer)(void*, uint32_t);
+typedef int32_t (*cli_apicall_int2)(struct cli_bc_ctx *, int32_t, int32_t);
+typedef int32_t (*cli_apicall_pointer)(struct cli_bc_ctx *, void*, uint32_t);
 
 struct cli_apicall {
     const char *name;
diff --git a/shared/optparser.c b/shared/optparser.c
index 893aeb1..8b03f15 100644
--- a/shared/optparser.c
+++ b/shared/optparser.c
@@ -118,6 +118,8 @@ const struct clam_option clam_options[] = {
     { NULL, "non-default", 'n', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMCONF, "", "" },
     { NULL, "generate-config", 'g', TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMCONF, "", "" },
 
+    { NULL, "force-interpreter", 'f', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "", "" },
+
     /* cmdline only - deprecated */
     { NULL, "http-proxy", 0, TYPE_STRING, NULL, 0, NULL, 0, OPT_FRESHCLAM | OPT_DEPRECATED, "", "" },
     { NULL, "proxy-user", 0, TYPE_STRING, NULL, 0, NULL, 0, OPT_FRESHCLAM | OPT_DEPRECATED, "", "" },
diff --git a/unit_tests/input/apicalls.cbc b/unit_tests/input/apicalls.cbc
index 551e0bc..fa94f94 100644
--- a/unit_tests/input/apicalls.cbc
+++ b/unit_tests/input/apicalls.cbc
@@ -1,6 +1,6 @@
 ClamBCaa`|`````|`afafp`clamcoincidencejb
 Tedacb`bb`bb`b
-Eabaaabbed|b`acflfifoebfcfaf`gifoedgefcgdgac``
+Eabaaabbed|afdgefcgdgac``
 A`b`bLacb`baab`bFadaa
 Bb`b``bbabHonnkm``odHm``oonnkdaaaadab`b`Hhgfedcbadb`babnaaaDm``odDmjnmdTcab`babE
 Aab`bLabahaab`bFacaa
diff --git a/unit_tests/input/apicalls2.cbc b/unit_tests/input/apicalls2.cbc
index ee97d74..a46b631 100644
--- a/unit_tests/input/apicalls2.cbc
+++ b/unit_tests/input/apicalls2.cbc
@@ -1,6 +1,6 @@
 ClamBCaa`|`````|`ajafp`clamcoincidencejb
 Tedcabidebidacb`bb`bb`bacb`bbidb`bebed
-Eabababbgd|b`acflfifoebfcfaf`gifoedgefcgdgac``aabhd|b`acflfifoebfcfaf`gifoedgefcgdg`c``
+Eabababbgd|afdgefcgdgac``aabhd|afdgefcgdg`c``
 A`b`bLahbedbfd`b`baab`baab`bFajac
 Bbfdaacb`@d at d``eb`aab`bac`bbabHonnkm``odHm``oonnkdaaaddab`bacHhgfedcbadTaaadaaab
 Bb`bae`bbaa`Honnkmjnmdaaafdab`baeHhgfedcbadb`bagnaafDm``odDmjnmdTcab`bag

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list