[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:06:31 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 9fac78c72ee6b4fe2e55397b896212e0a12bae30
Author: Török Edvin <edwin at clamav.net>
Date: Fri Oct 2 10:26:47 2009 +0300
Update to latest bytecode format.
diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c
index b887f60..d686998 100644
--- a/libclamav/bytecode.c
+++ b/libclamav/bytecode.c
@@ -379,6 +379,7 @@ static int parseHeader(struct cli_bc *bc, unsigned char *buffer)
bc->verifier = readNumber(buffer, &offset, len, &ok);
bc->sigmaker = readString(buffer, &offset, len, &ok);
bc->id = readNumber(buffer, &offset, len, &ok);
+ bc->kind = readNumber(buffer, &offset, len, &ok);
bc->metadata.maxStack = readNumber(buffer, &offset, len, &ok);
bc->metadata.maxMem = readNumber(buffer, &offset, len, &ok);
bc->metadata.maxTime = readNumber(buffer, &offset, len, &ok);
@@ -723,12 +724,18 @@ static void readConstant(struct cli_bc *bc, unsigned i, unsigned comp,
static int parseGlobals(struct cli_bc *bc, unsigned char *buffer)
{
unsigned i, offset = 1, len = strlen((const char*)buffer), numglobals;
+ unsigned maxglobal;
char ok=1;
if (buffer[0] != 'G') {
cli_errmsg("bytecode: Invalid globals header: %c\n", buffer[0]);
return CL_EMALFDB;
}
+ maxglobal = readNumber(buffer, &offset, len, &ok);
+ if (maxglobal > cli_apicall_maxglobal) {
+ cli_dbgmsg("bytecode using global %u, but highest global known to libclamav is %u, skipping\n", maxglobal, cli_apicall_maxglobal);
+ return CL_BREAK;
+ }
numglobals = readNumber(buffer, &offset, len, &ok);
bc->globals = cli_calloc(numglobals, sizeof(*bc->globals));
if (!bc->globals) {
diff --git a/libclamav/bytecode.h b/libclamav/bytecode.h
index 04ba9c8..1cf9d98 100644
--- a/libclamav/bytecode.h
+++ b/libclamav/bytecode.h
@@ -44,6 +44,7 @@ struct cli_bc {
unsigned verifier;
char *sigmaker;
unsigned id;
+ unsigned kind;
struct bytecode_metadata metadata;
unsigned num_types;
unsigned num_func;
diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
index b875451..aa22714 100644
--- a/libclamav/c++/bytecode2llvm.cpp
+++ b/libclamav/c++/bytecode2llvm.cpp
@@ -196,6 +196,7 @@ private:
LLVMTypeMapper *TypeMap;
Function **apiFuncs;
FunctionMapTy &compiledFunctions;
+ LLVMTypeMapper &apiMap;
Twine BytecodeID;
ExecutionEngine *EE;
TargetFolder Folder;
@@ -350,13 +351,14 @@ private:
public:
LLVMCodegen(const struct cli_bc *bc, Module *M, FunctionMapTy &cFuncs,
- ExecutionEngine *EE, FunctionPassManager &PM, Function **apiFuncs)
+ ExecutionEngine *EE, FunctionPassManager &PM,
+ Function **apiFuncs, LLVMTypeMapper &apiMap)
: bc(bc), M(M), Context(M->getContext()), compiledFunctions(cFuncs),
BytecodeID("bc"+Twine(bc->id)), EE(EE),
Folder(EE->getTargetData(), Context), Builder(Context, Folder), PM(PM),
- apiFuncs(apiFuncs)
+ apiFuncs(apiFuncs), apiMap(apiMap)
{
- for (unsigned i=0;i<cli_apicall_maxglobal;i++) {
+ for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
unsigned id = cli_globals[i].globalid;
GVoffsetMap[id] = cli_globals[i].offset;
}
@@ -365,9 +367,9 @@ public:
bool generate() {
TypeMap = new LLVMTypeMapper(Context, bc->types + 4, bc->num_types - 5);
- for (unsigned i=0;i<cli_apicall_maxglobal;i++) {
+ for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
unsigned id = cli_globals[i].globalid;
- GVtypeMap[id] = TypeMap->get(cli_globals[i].type);
+ GVtypeMap[id] = apiMap.get(cli_globals[i].type);
}
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context),
false);
@@ -891,7 +893,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
if (bc->state == bc_skip)
continue;
LLVMCodegen Codegen(bc, M, bcs->engine->compiledFunctions, EE,
- OurFPM, apiFuncs);
+ OurFPM, apiFuncs, apiMap);
if (!Codegen.generate()) {
errs() << MODULE << "JIT codegen failed\n";
return CL_EBYTECODE;
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list