Skip to content

Commit

Permalink
Merge pull request #282 from tklengyel/coverity
Browse files Browse the repository at this point in the history
Coverity fixes
  • Loading branch information
tklengyel authored Jun 28, 2017
2 parents 1f1bfe1 + 34023d6 commit 5e70b21
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/drakvuf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*********************IMPORTANT DRAKVUF LICENSE TERMS***********************
* *
* DRAKVUF (C) 2014-2016 Tamas K Lengyel. *
* DRAKVUF (C) 2014-2017 Tamas K Lengyel. *
* Tamas K Lengyel is hereinafter referred to as the author. *
* This program is free software; you may redistribute and/or modify it *
* under the terms of the GNU General Public License as published by the *
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/filedelete/filedelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ static void extract_ca_file(filedelete *f, drakvuf_t drakvuf, vmi_instance_t vmi
if ( VMI_FAILURE == vmi_read_addr(vmi, ctx, &test) || test != control_area )
break;

addr_t base;
uint32_t ptes, start;
addr_t base = 0, start = 0;
uint32_t ptes = 0;

ctx->addr = subsection + f->offsets[SUBSECTION_SUBSECTIONBASE];
if ( VMI_FAILURE == vmi_read_addr(vmi, ctx, &base) )
Expand All @@ -204,7 +204,7 @@ static void extract_ca_file(filedelete *f, drakvuf_t drakvuf, vmi_instance_t vmi
break;

ctx->addr = subsection + f->offsets[SUBSECTION_STARTINGSECTOR];
if ( VMI_FAILURE == vmi_read_32(vmi, ctx, &start) )
if ( VMI_FAILURE == vmi_read_32(vmi, ctx, (uint32_t*)&start) )
break;

/*
Expand All @@ -230,8 +230,8 @@ static void extract_ca_file(filedelete *f, drakvuf_t drakvuf, vmi_instance_t vmi
if ( 4096 != vmi_read_pa(vmi, VMI_BIT_MASK(12,48) & pte, page, 4096) )
continue;

fseek ( fp , fileoffset , SEEK_SET );
fwrite(page, 4096, 1, fp);
if ( !fseek ( fp , fileoffset , SEEK_SET ) )
fwrite(page, 4096, 1, fp);
}
}

Expand Down
15 changes: 11 additions & 4 deletions src/plugins/poolmon/poolmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static event_response_t cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {
page_mode_t pm = vmi_get_page_mode(vmi, 0);
reg_t pool_type, size;
char tag[5] = { [0 ... 4] = '\0' };
struct pooltag *s = NULL;

access_context_t ctx;
ctx.translate_mechanism = VMI_TM_PROCESS_DTB;
Expand All @@ -151,14 +152,19 @@ static event_response_t cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {
*(reg_t*)tag = info->regs->r8;
} else {
ctx.addr = info->regs->rsp+12;
vmi_read_32(vmi, &ctx, (uint32_t*)tag);
if ( VMI_FAILURE == vmi_read_32(vmi, &ctx, (uint32_t*)tag) )
goto done;

ctx.addr = info->regs->rsp+8;
vmi_read_32(vmi, &ctx, (uint32_t*)&size);
if ( VMI_FAILURE == vmi_read_32(vmi, &ctx, (uint32_t*)&size) )
goto done;

ctx.addr = info->regs->rsp+4;
vmi_read_32(vmi, &ctx, (uint32_t*)&pool_type);
if ( VMI_FAILURE == vmi_read_32(vmi, &ctx, (uint32_t*)&pool_type) )
goto done;
}

struct pooltag *s = (struct pooltag*)g_tree_lookup(p->pooltag_tree, tag);
s = (struct pooltag*)g_tree_lookup(p->pooltag_tree, tag);

switch(p->format) {
case OUTPUT_CSV:
Expand All @@ -184,6 +190,7 @@ static event_response_t cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {

printf("\n");

done:
drakvuf_release_vmi(drakvuf);
return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/socketmon/socketmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,9 @@ static event_response_t tcpl_cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {

drakvuf_release_vmi(drakvuf);

if ( !w->obj )
return 0;

drakvuf_trap_t *trap = (drakvuf_trap_t*)g_malloc0(sizeof(drakvuf_trap_t));
trap->breakpoint.lookup_type = LOOKUP_PID;
trap->breakpoint.pid = 4;
Expand Down Expand Up @@ -1198,6 +1201,9 @@ static event_response_t udpb_cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {

drakvuf_release_vmi(drakvuf);

if ( !w->obj )
return 0;

drakvuf_trap_t *trap = (drakvuf_trap_t*)g_malloc0(sizeof(drakvuf_trap_t));
trap->breakpoint.lookup_type = LOOKUP_PID;
trap->breakpoint.pid = 4;
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/socketmon/socketmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class socketmon: public plugin {
.data = (void*)this
}
};
GSList *writetraps;
GHashTable *rettraps;

socketmon(drakvuf_t drakvuf, const void *config, output_format_t output);
~socketmon();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/syscalls/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static unicode_string_t* get_filename_from_handle(syscalls *s,
}

static event_response_t win_cb(drakvuf_t drakvuf, drakvuf_trap_info_t *info) {
int i = 0, nargs = 0;
unsigned int i = 0, nargs = 0;
size_t size = 0;
unsigned char* buf = NULL; // pointer to buffer to hold argument values

Expand Down

0 comments on commit 5e70b21

Please sign in to comment.