Skip to content

Commit

Permalink
Fix error handling in injector_int3_cb (CID 307533)
Browse files Browse the repository at this point in the history
Fix error handling in injector_int3_cb in win_injector.c by
checking the return value from vmi_read. This prevents a call
to vmi_convert_str_encoding(...) passing uninitialized data.
This issue was identified by coverity as CID 307533
  • Loading branch information
jgru committed Jul 11, 2021
1 parent 2a1b258 commit 990b8a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libinjector/win_injector.c
Expand Up @@ -1443,7 +1443,7 @@ static event_response_t injector_int3_cb(drakvuf_t drakvuf, drakvuf_trap_info_t*
return 0;
}

uint8_t buf[FILE_BUF_SIZE];
uint8_t buf[FILE_BUF_SIZE] = {0};;
unicode_string_t in;

ACCESS_CONTEXT(ctx);
Expand All @@ -1458,7 +1458,13 @@ static event_response_t injector_int3_cb(drakvuf_t drakvuf, drakvuf_trap_info_t*
}

vmi = drakvuf_lock_and_get_vmi(drakvuf);
vmi_read(vmi, &ctx, regs.x86.rax * 2, buf, NULL);
if (VMI_SUCCESS != vmi_read(vmi, &ctx, regs.x86.rax * 2, buf, NULL))
{
drakvuf_release_vmi(drakvuf);
PRINT_DEBUG("Failed to read buffer at %lx\n", regs.x86.rax * 2);
return 0;
}

drakvuf_release_vmi(drakvuf);
in.contents = buf;
in.length = regs.x86.rax * 2;
Expand Down

0 comments on commit 990b8a2

Please sign in to comment.