From 7c9c4fab2274eaf7fc911a0263d2c983be7975c2 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Tue, 26 Aug 2014 17:02:41 -0400 Subject: [PATCH] bytecode: various changes from code review --- libclamav/bytecode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c index 9c49a86fb..5c6a2a8c4 100644 --- a/libclamav/bytecode.c +++ b/libclamav/bytecode.c @@ -3100,7 +3100,6 @@ static void cli_bytetype_helper(const struct cli_bc *bc, unsigned tid) unsigned i, j; const struct cli_bc_type *ty; - if (tid & 0x8000) { printf("alloc "); tid &= 0x7fff; @@ -3112,7 +3111,10 @@ static void cli_bytetype_helper(const struct cli_bc *bc, unsigned tid) } i = tid - 65; - + if (i >= bc->num_types) { + printf("invaltype"); + return; + } ty = &bc->types[i]; switch (ty->kind) { @@ -3229,7 +3231,7 @@ void cli_byteinst_describe(const struct cli_bc_inst *inst, unsigned *bbnum) return; } - snprintf(inst_str, 256, "%-20s[%-3d/%3d/%3d]", bc_opstr[inst->opcode], + snprintf(inst_str, sizeof(inst_str), "%-20s[%-3d/%3d/%3d]", bc_opstr[inst->opcode], inst->opcode, inst->interp_op, inst->interp_op%inst->opcode); printf("%-35s", inst_str); switch (inst->opcode) {