Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dex fixes #1728

Merged
merged 2 commits into from
Jun 15, 2022
Merged
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
23 changes: 13 additions & 10 deletions libyara/modules/dex/dex.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ uint32_t load_encoded_field(
{
#ifdef DEBUG_DEX_MODULE
printf(
"[DEX]\tFIELD_NAME %s NAME_IDX 0x%x\n", field_name->c_string, name_idx);
"[DEX]\tFIELD_NAME %s NAME_IDX 0x%llx\n", field_name->c_string, name_idx);
#endif

set_sized_string(
Expand All @@ -643,7 +643,7 @@ uint32_t load_encoded_field(
{
#ifdef DEBUG_DEX_MODULE
printf(
"[DEX]\tCLASS_NAME %s CLASS_IDX 0x%x DESCRIPTOR_IDX 0x%x\n",
"[DEX]\tCLASS_NAME %s CLASS_IDX 0x%llx DESCRIPTOR_IDX 0x%llx\n",
class_name->c_string,
class_idx,
descriptor_idx);
Expand Down Expand Up @@ -748,7 +748,7 @@ uint32_t load_encoded_method(
return 0;

#ifdef DEBUG_DEX_MODULE
printf("[DEX]\tNAME_IDX 0x%x\n", name_idx);
printf("[DEX]\tNAME_IDX 0x%llx\n", name_idx);
#endif

#ifdef DEBUG_DEX_MODULE
Expand All @@ -768,7 +768,7 @@ uint32_t load_encoded_method(
{
#ifdef DEBUG_DEX_MODULE
printf(
"[DEX]\tMETHOD_NAME %s NAME_IDX 0x%x\n",
"[DEX]\tMETHOD_NAME %s NAME_IDX 0x%llx\n",
method_name->c_string,
name_idx);
#endif
Expand All @@ -794,7 +794,7 @@ uint32_t load_encoded_method(
{
#ifdef DEBUG_DEX_MODULE
printf(
"[DEX]\tCLASS_NAME %s CLASS_IDX 0x%x DESCRIPTOR_IDX:0x%x\n",
"[DEX]\tCLASS_NAME %s CLASS_IDX 0x%llx DESCRIPTOR_IDX:0x%llx\n",
class_name->c_string,
class_idx,
descriptor_idx);
Expand All @@ -821,7 +821,7 @@ uint32_t load_encoded_method(
{
#ifdef DEBUG_DEX_MODULE
printf(
"[DEX]\tPROTO_NAME %s CLASS_IDX 0x%x DESCRIPTOR_IDX:0x%x\n",
"[DEX]\tPROTO_NAME %s CLASS_IDX 0x%llx DESCRIPTOR_IDX:0x%llx\n",
proto_name->c_string,
class_idx,
descriptor_idx);
Expand All @@ -842,7 +842,7 @@ uint32_t load_encoded_method(
#endif

if (struct_fits_in_dex(
dex, dex->data + encoded_method.code_off, sizeof(code_item_t)))
dex, dex->data + encoded_method.code_off, code_item_t))
{
code_item_t* code_item =
(code_item_t*) (dex->data + encoded_method.code_off);
Expand Down Expand Up @@ -954,7 +954,7 @@ void dex_parse(DEX* dex, uint64_t base_address)

if (!fits_in_dex(
dex,
dex->data + yr_le32toh(string_id_item->string_data_offset),
dex->data + yr_le32toh(string_id_item->string_data_offset) + 1,
value))
continue;

Expand All @@ -967,8 +967,8 @@ void dex_parse(DEX* dex, uint64_t base_address)
set_integer(value, dex->object, "string_ids[%i].size", i);

set_sized_string(
(const char*) ((
dex->data + yr_le32toh(string_id_item->string_data_offset) + 1)),
(const char*) (
dex->data + yr_le32toh(string_id_item->string_data_offset) + 1),
value,
dex->object,
"string_ids[%i].value",
Expand Down Expand Up @@ -1124,6 +1124,9 @@ void dex_parse(DEX* dex, uint64_t base_address)
map_item_t* map_item =
(map_item_t*) (dex->data + yr_le32toh(dex_header->map_offset) + sizeof(uint32_t) + i * sizeof(map_item_t));

if (!struct_fits_in_dex(dex, map_item, map_item_t))
return;

set_integer(
yr_le16toh(map_item->type),
dex->object,
Expand Down