[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:16:08 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 4395bb9acf0a80ee7ac5dddbdd965bd3779a19a3
Author: Török Edvin <edwin at clamav.net>
Date: Thu Jan 21 16:48:56 2010 +0200
bytecode ptrdiff32 opcode.
diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c
index 03aae93..e85cd8b 100644
--- a/libclamav/bytecode_api.c
+++ b/libclamav/bytecode_api.c
@@ -59,9 +59,18 @@ uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx, uint32_t a)
int32_t cli_bcapi_read(struct cli_bc_ctx* ctx, uint8_t *data, int32_t size)
{
+ int n;
if (!ctx->fmap)
return -1;
- return fmap_readn(ctx->fmap, data, ctx->off, size);
+ if (size < 0) {
+ cli_errmsg("bytecode: negative read size: %d\n", size);
+ return -1;
+ }
+ n = fmap_readn(ctx->fmap, data, ctx->off, size);
+ if (n <= 0)
+ return n;
+ ctx->off += n;
+ return n;
}
int32_t cli_bcapi_seek(struct cli_bc_ctx* ctx, int32_t pos, uint32_t whence)
diff --git a/libclamav/bytecode_api.h b/libclamav/bytecode_api.h
index d5192a6..d3fe23a 100644
--- a/libclamav/bytecode_api.h
+++ b/libclamav/bytecode_api.h
@@ -81,7 +81,7 @@ uint32_t test1(uint32_t, uint32_t);
/**
* @brief Reads specified amount of bytes from the current file
- * into a buffer.
+ * into a buffer. Also moves current position in the file.
*
* @param[in] size amount of bytes to read
* @param[out] data pointer to buffer where data is read into
diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
index aa6df15..c22d0e8 100644
--- a/libclamav/c++/bytecode2llvm.cpp
+++ b/libclamav/c++/bytecode2llvm.cpp
@@ -182,6 +182,9 @@ static void* noUnknownFunctions(const std::string& name) {
.Case("__ashrdi3", (void*)(intptr_t)rtlib_sra_i64)
.Case("__ashldi3", (void*)(intptr_t)rtlib_shl_i64)
.Case("__lshrdi3", (void*)(intptr_t)rtlib_srl_i64)
+ .Case("memmove", (void*)(intptr_t)memmove)
+ .Case("memcpy", (void*)(intptr_t)memcpy)
+ .Case("memset", (void*)(intptr_t)memset)
.Default(0);
if (addr)
return addr;
@@ -1132,7 +1135,17 @@ public:
Store(inst->dest, C);
break;
}
-
+ case OP_BC_PTRDIFF32:
+ {
+ Value *P1 = convertOperand(func, inst, inst->u.binop[0]);
+ Value *P2 = convertOperand(func, inst, inst->u.binop[1]);
+ P1 = Builder.CreatePtrToInt(P1, Type::getInt64Ty(Context));
+ P2 = Builder.CreatePtrToInt(P2, Type::getInt64Ty(Context));
+ Value *R = Builder.CreateSub(P1, P2);
+ R = Builder.CreateTrunc(R, Type::getInt32Ty(Context));
+ Store(inst->dest, R);
+ break;
+ }
default:
errs() << MODULE << "JIT doesn't implement opcode " <<
inst->opcode << " yet!\n";
diff --git a/libclamav/clambc.h b/libclamav/clambc.h
index 0e5ef72..9336428 100644
--- a/libclamav/clambc.h
+++ b/libclamav/clambc.h
@@ -83,6 +83,7 @@ enum bc_opcode {
OP_BC_BSWAP16,
OP_BC_BSWAP32,
OP_BC_BSWAP64,
+ OP_BC_PTRDIFF32,
OP_BC_INVALID /* last */
};
@@ -108,8 +109,8 @@ static const unsigned char operand_counts[] = {
3, 3, 3, 3,
/* OP_BC_ISBIGENDIAN */
0,
- /* OP_BC_ABORT, OP_BSWAP* */
- 0, 1, 1, 1
+ /* OP_BC_ABORT, OP_BSWAP*, OP_PTRDIFF32 */
+ 0, 1, 1, 1, 2
};
enum bc_global {
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list