Skip to content

Commit

Permalink
Fix some vmi_read_str memory leaks (#1786)
Browse files Browse the repository at this point in the history
* Fix memory leak in linux procmon

* Fix memory leak in _cr3_cb

* Fix memory leak in linux_eprocess_sym2va
  • Loading branch information
alex-pentagrid authored Apr 2, 2024
1 parent 9613886 commit 0d7f7c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libdrakvuf/linux-exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,12 @@ addr_t linux_eprocess_sym2va(drakvuf_t drakvuf, addr_t eprocess_base, const char
addr_t symbol_size = strlen(symbol_name);
if (strcmp(symbol_name, sym) == 0)
{
g_free(symbol_name);
sym_found = true;
break;
}
symbol_offset += symbol_size+1;
g_free(symbol_name);
}

if (!sym_found)
Expand Down
2 changes: 2 additions & 0 deletions src/libdrakvuf/vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ static event_response_t _cr3_cb(drakvuf_t drakvuf, vmi_event_t* event)

process = process->next;
}

g_free(process_name);
}

free_proc_data_priv_2(&proc_data, &attached_proc_data);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/procmon/linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,14 @@ event_response_t linux_procmon::execve_cb(drakvuf_t drakvuf, drakvuf_trap_info_t
params->setResultCallParams(drakvuf, info);
params->bprm = drakvuf_get_function_argument(drakvuf, info, 1);
params->process_name = info->proc_data.name;
params->thread_name = drakvuf_get_process_name(drakvuf, info->proc_data.base_addr, false);
char* thread_name = drakvuf_get_process_name(drakvuf, info->proc_data.base_addr, false);
params->thread_name = thread_name ?: "";
params->old_creds = get_current_credentials(drakvuf, info);

uint64_t hookID = make_hook_id(info);
this->ret_hooks[hookID] = std::move(hook);

g_free(thread_name);
return VMI_EVENT_RESPONSE_NONE;
}

Expand Down

0 comments on commit 0d7f7c1

Please sign in to comment.