Check number of functions loaded.

0.96
Török Edvin 17 years ago
parent e0c4fd853c
commit 957bf65143
  1. 6
      libclamav/bytecode.c
  2. 2
      libclamav/bytecode_vm.c

@ -52,6 +52,7 @@ int cli_bytecode_context_clear(struct cli_bc_ctx *ctx)
free(ctx->values);
free(ctx->operands);
memset(ctx, 0, sizeof(ctx));
return CL_SUCCESS;
}
int cli_bytecode_context_setfuncid(struct cli_bc_ctx *ctx, struct cli_bc *bc, unsigned funcid)
@ -597,6 +598,11 @@ int cli_bytecode_load(struct cli_bc *bc, FILE *f, struct cli_dbio *dbio)
}
}
cli_dbgmsg("Parsed %d functions\n", current_func);
if (current_func != bc->num_func) {
cli_errmsg("Loaded less functions than declared: %u vs. %u\n",
current_func, bc->num_func);
return CL_EMALFDB;
}
return CL_SUCCESS;
}

@ -42,7 +42,7 @@ static int bcfail(const char *msg, unsigned a, unsigned b,
bcfail("funcid out of bounds!",funcid, bc->num_func,__FILE__,__LINE__); } while(0)
#define CHECK_EQ(a, b) do { if (a != b) return \
bcfail("Values "#a" and "#b" don't match!",a,b,__FILE__,__LINE__); } while(0)
#define CHECK_GT(a, b) do {if (a < b) return \
#define CHECK_GT(a, b) do {if (a <= b) return \
bcfail("Condition failed "#a" > "#b,a,b, __FILE__, __LINE__); } while(0)
#else
#define CHECK_FUNCID(x)

Loading…
Cancel
Save