bytecode_vm: fix memset on bigendian arch (bb #2478).

Otherwise memset's count is always 0, and we are using uninitialized bytes,
causing bytecode to misbehave.
remotes/push_mirror/vc9-vt-dnd
Török Edvin 15 years ago
parent ab402e6aae
commit ecedf8a9f9
  1. 4
      ChangeLog
  2. 20
      libclamav/bytecode_vm.c

@ -1,3 +1,7 @@
Thu Jan 20 16:09:29 EET 2011 (edwin)
-----------------------------------
* libclamav/bytecode_vm.c: fix memset on bigendian arch (bb #2478).
Thu Jan 20 11:38:33 EET 2011 (edwin)
------------------------------------
* libclamav/pdf.c: fix missed detection (bb #2455).

@ -226,7 +226,6 @@ static always_inline struct stack_entry *allocate_stack(struct stack *stack,
entry->bb_inst = bb_inst;
/* we allocated room for values right after stack_entry! */
entry->values = values = (char*)&entry[1];
memcpy(&values[func->numBytes - func->numConstants*8], func->constants,
sizeof(*values)*func->numConstants*8);
return entry;
@ -1125,40 +1124,41 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct
break;
}
DEFINE_OP(OP_BC_MEMCPY) {
int32_t arg3;
int64_t arg3;
void *arg1, *arg2;
int64_t res=0;
READ32(arg3, inst->u.three[2]);
READ64(arg3, inst->u.three[2]);
READPOP(arg1, inst->u.three[0], arg3);
READPOP(arg2, inst->u.three[1], arg3);
memcpy(arg1, arg2, arg3);
memcpy(arg1, arg2, (int32_t)arg3);
/* READ64(res, inst->u.three[0]);*/
WRITE64(inst->dest, res);
break;
}
DEFINE_OP(OP_BC_MEMMOVE) {
int32_t arg3;
int64_t arg3;
void *arg1, *arg2;
int64_t res=0;
READ32(arg3, inst->u.three[2]);
READ64(arg3, inst->u.three[2]);
READPOP(arg1, inst->u.three[0], arg3);
READPOP(arg2, inst->u.three[1], arg3);
memmove(arg1, arg2, arg3);
memmove(arg1, arg2, (int32_t)arg3);
/* READ64(res, inst->u.three[0]);*/
WRITE64(inst->dest, res);
break;
}
DEFINE_OP(OP_BC_MEMSET) {
int32_t arg2, arg3;
int64_t arg3;
int32_t arg2;
void *arg1;
int64_t res=0;
READ32(arg3, inst->u.three[2]);
READ64(arg3, inst->u.three[2]);
READPOP(arg1, inst->u.three[0], arg3);
READ32(arg2, inst->u.three[1]);
memset(arg1, arg2, arg3);
memset(arg1, arg2, (int32_t)arg3);
/* READ64(res, inst->u.three[0]);*/
WRITE64(inst->dest, res);
break;

Loading…
Cancel
Save