Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clamav-milter/netcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ int islocalnet_name(char *name)

int islocalnet_sock(struct sockaddr *sa)
{
uint32_t host[4], family;
uint32_t host[4] = {0};
uint32_t family;

if (!lnet) return 0;

Expand Down
14 changes: 13 additions & 1 deletion libclamav/autoit.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ static cl_error_t ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd)
cli_dbgmsg("autoit: file is compressed\n");
if (cli_readint32(UNP.inputbuf) != 0x35304145) {
cli_dbgmsg("autoit: bad magic or unsupported version\n");
// Free this inputbuf and set back to NULL.
free(UNP.inputbuf);
UNP.inputbuf = NULL;

continue;
}

Expand All @@ -769,6 +773,10 @@ static cl_error_t ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd)
}

if (cli_checklimits("autoit", ctx, UNP.usize, 0, 0) != CL_CLEAN) {
// Free this inputbuf and set back to NULL.
free(UNP.inputbuf);
UNP.inputbuf = NULL;

continue;
}

Expand Down Expand Up @@ -848,12 +856,16 @@ static cl_error_t ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd)
*/
cli_dbgmsg("autoit: file is not compressed\n");
UNP.outputbuf = UNP.inputbuf;
UNP.usize = UNP.csize;
UNP.inputbuf = NULL;

UNP.usize = UNP.csize;
}

if (UNP.usize < 4) {
cli_dbgmsg("autoit: file is too short\n");
free(UNP.outputbuf);
UNP.outputbuf = NULL;

continue;
}

Expand Down
41 changes: 34 additions & 7 deletions libclamav/bytecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,10 @@ static cl_error_t parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigne
BB->insts = &bcfunc->allinsts[bcfunc->insn_idx];
while (!last) {
unsigned numOp;

// Initialize instruction to zero
memset(&inst, 0, sizeof(inst));

if (buffer[offset] == 'T') {
last = 1;
offset++;
Expand Down Expand Up @@ -1355,6 +1359,33 @@ static cl_error_t parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigne
inst.u.ops.ops[i] = readOperand(bcfunc, buffer, &offset, len, &ok);
}
break;
case OP_BC_STORE:
numOp = operand_counts[inst.opcode];
if (2 != numOp) {
// invalid number of operands
cli_errmsg("Invalid number of operands (%u) for OP_BC_STORE opcode\n", numOp);
return CL_EMALFDB;
}
inst.u.binop[0] = readOperand(bcfunc, buffer, &offset, len, &ok);
inst.u.binop[1] = readOperand(bcfunc, buffer, &offset, len, &ok);

int16_t t = get_optype(bcfunc, inst.u.binop[0]);
if (t) {
inst.type = t;
}
break;
case OP_BC_COPY:
numOp = operand_counts[inst.opcode];
if (2 != numOp) {
// invalid number of operands
cli_errmsg("Invalid number of operands (%u) for OP_BC_COPY opcode\n", numOp);
return CL_EMALFDB;
}
inst.u.binop[0] = readOperand(bcfunc, buffer, &offset, len, &ok);
inst.u.binop[1] = readOperand(bcfunc, buffer, &offset, len, &ok);

inst.type = get_optype(bcfunc, inst.u.binop[1]);
break;
case OP_BC_ICMP_EQ:
case OP_BC_ICMP_NE:
case OP_BC_ICMP_UGT:
Expand Down Expand Up @@ -1391,22 +1422,18 @@ static cl_error_t parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigne
break;
}
}
if (inst.opcode == OP_BC_STORE) {
int16_t t = get_optype(bcfunc, inst.u.binop[0]);
if (t)
inst.type = t;
}
if (inst.opcode == OP_BC_COPY)
inst.type = get_optype(bcfunc, inst.u.binop[1]);

if (!ok) {
cli_errmsg("Invalid instructions or operands\n");
return CL_EMALFDB;
}

if (bcfunc->insn_idx + BB->numInsts >= bcfunc->numInsts) {
cli_errmsg("More instructions than declared in total: %u > %u!\n",
bcfunc->insn_idx + BB->numInsts, bcfunc->numInsts);
return CL_EMALFDB;
}

inst.interp_op = inst.opcode * 5;
if (inst.type > 1) {
if (inst.type <= 8)
Expand Down
Loading