[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:22:08 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 20327f931ffabc410cebba9c9a8b864aaa382b1f
Author: Török Edvin <edwin at clamav.net>
Date: Sat Mar 6 16:28:08 2010 +0200
compute global offsets.
diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c
index dd5ebd0..d56c440 100644
--- a/libclamav/bytecode.c
+++ b/libclamav/bytecode.c
@@ -1475,10 +1475,15 @@ void cli_bytecode_destroy(struct cli_bc *bc)
#define MAP(val) do { operand_t o = val; \
if (o & 0x80000000) {\
o &= 0x7fffffff;\
- o = bcfunc->numValues + bcfunc->numConstants + o;\
+ if (o > bc->num_globals) {\
+ cli_errmsg("bytecode: global out of range: %u > %u, for instruction %u in function %u\n",\
+ o, bc->num_globals, j, i);\
+ return CL_EBYTECODE;\
+ }\
+ val = 0x80000000 | gmap[o];\
+ break;\
}\
if (o > totValues) {\
- printf("%d\n", _FIRST_GLOBAL);\
cli_errmsg("bytecode: operand out of range: %u > %u, for instruction %u in function %u\n", o, totValues, j, i);\
return CL_EBYTECODE;\
}\
@@ -1487,11 +1492,26 @@ void cli_bytecode_destroy(struct cli_bc *bc)
static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
{
unsigned i, j, k;
+ unsigned *gmap;
+ bc->numGlobalBytes = 0;
+ gmap = cli_malloc(bc->num_globals*sizeof(*gmap));
+ if (!gmap)
+ return CL_EMEM;
+ for (j=0;j<bc->num_globals;j++) {
+ uint16_t ty = bc->globaltys[j];
+ unsigned align = typealign(bc, ty);
+ assert(align);
+ bc->numGlobalBytes = (bc->numGlobalBytes + align-1)&(~(align-1));
+ gmap[j] = bc->numGlobalBytes;
+ bc->numGlobalBytes += typesize(bc, ty);
+ }
for (i=0;i<bc->num_func;i++) {
struct cli_bc_func *bcfunc = &bc->funcs[i];
unsigned totValues = bcfunc->numValues + bcfunc->numConstants + bc->num_globals;
unsigned *map = cli_malloc(sizeof(*map)*totValues);
+ if (!map)
+ return CL_EMEM;
bcfunc->numBytes = 0;
for (j=0;j<bcfunc->numValues;j++) {
uint16_t ty = bcfunc->types[j];
@@ -1507,14 +1527,6 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
map[bcfunc->numValues+j] = bcfunc->numBytes;
bcfunc->numBytes += 8;
}
- for (j=0;j<bc->num_globals;j++) {
- uint16_t ty = bc->globaltys[j];
- unsigned align = typealign(bc, ty);
- assert(align);
- bcfunc->numBytes = (bcfunc->numBytes + align-1)&(~(align-1));
- map[bcfunc->numValues+bcfunc->numConstants+j] = bcfunc->numBytes;
- bcfunc->numBytes += typesize(bc, ty);
- }
for (j=0;j<bcfunc->numInsts;j++) {
struct cli_bc_inst *inst = &bcfunc->allinsts[j];
inst->dest = map[inst->dest];
@@ -1646,6 +1658,7 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
}
free(map);
}
+ free(gmap);
bc->state = bc_interp;
return CL_SUCCESS;
}
diff --git a/libclamav/bytecode.h b/libclamav/bytecode.h
index 6bba27c..80e242a 100644
--- a/libclamav/bytecode.h
+++ b/libclamav/bytecode.h
@@ -66,6 +66,8 @@ struct cli_bc {
unsigned dbgnode_cnt;
unsigned hook_lsig_id;
unsigned trusted;
+ uint32_t numGlobalBytes;
+ uint8_t *globalBytes;
};
struct cli_all_bc {
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list