[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 00:53:36 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit a0d6fec082d4baaeb478554208cb675a058c16a0
Author: Török Edvin <edwin at clamav.net>
Date:   Mon Jun 29 17:57:02 2009 +0300

    Add support for internal function calls to bytecode loader.

diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c
index ff4cca7..a9da3d3 100644
--- a/libclamav/bytecode.c
+++ b/libclamav/bytecode.c
@@ -388,6 +388,20 @@ static int parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigned char
 		inst.u.branch.br_true = readBBID(bcfunc, buffer, &offset, len, &ok);
 		inst.u.branch.br_false = readBBID(bcfunc, buffer, &offset, len, &ok);
 		break;
+	    case OP_CALL_DIRECT:
+		numOp = readFixedNumber(buffer, &offset, len, &ok, 1)+1;
+		if (ok) {
+		    inst.u.ops.numOps = numOp;
+		    inst.u.ops.ops = cli_calloc(numOp, sizeof(*inst.u.ops.ops));
+		    if (!inst.u.ops.ops) {
+			cli_errmsg("Out of memory allocating operands\n");
+			return CL_EMALFDB;
+		    }
+		    for (i=0;i<numOp;i++) {
+			inst.u.ops.ops[i] = readOperand(buffer, &offset, len, &ok);
+		    }
+		}
+		break;
 	    default:
 		numOp = operand_counts[inst.opcode];
 		switch (numOp) {
@@ -404,15 +418,8 @@ static int parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigned char
 			inst.u.three[2] = readOperand(buffer, &offset, len, &ok);
 			break;
 		    default:
-			inst.u.ops.numOps = numOp;
-			inst.u.ops.ops = cli_calloc(numOp, sizeof(*inst.u.ops.ops));
-			if (!inst.u.ops.ops) {
-			    cli_errmsg("Out of memory allocating operands\n");
-			    return CL_EMALFDB;
-			}
-			for (i=0;i<numOp;i++) {
-			    inst.u.ops.ops[i] = readOperand(buffer, &offset, len, &ok);
-			}
+			cli_errmsg("Opcode with too many operands: %u?\n", numOp);
+			ok = 0;
 			break;
 		}
 	}
diff --git a/libclamav/clambc.h b/libclamav/clambc.h
index 4c40a81..0dba92c 100644
--- a/libclamav/clambc.h
+++ b/libclamav/clambc.h
@@ -65,6 +65,7 @@ enum bc_opcode {
   OP_ICMP_SLE,
   OP_ICMP_SLT,
   OP_SELECT,
+  OP_CALL_DIRECT,
   OP_INVALID /* last */
 };
 
@@ -79,6 +80,8 @@ static const unsigned char operand_counts[] = {
   /* ICMP */
   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
   /* SELECT */
-  3
+  3,
+  /* CALLs have variable number of operands */
+  0
 };
 #endif

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list