summaryrefslogtreecommitdiff
path: root/src/format/dex/pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/dex/pool.c')
-rw-r--r--src/format/dex/pool.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index dbcee52..b2ca105 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -48,6 +48,9 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)
string_id_item str_id; /* Identifiant de chaîne */
string_data_item str_data; /* Description de chaîne */
+ if (index >= format->header.string_ids_size)
+ return NULL;
+
pos = format->header.string_ids_off + index * sizeof(string_id_item);
if (!read_dex_string_id_item(format, &pos, &str_id))
@@ -92,6 +95,9 @@ GOpenidaType *get_type_from_dex_pool(const GDexFormat *format, uint16_t index)
//printf("Index :: 0x%04hx\n", index);
+ if (index >= format->header.type_ids_size)
+ return NULL;
+
pos = format->header.type_ids_off + index * sizeof(type_id_item);
if (!read_dex_type_id_item(format, &pos, &type_id))
@@ -135,12 +141,15 @@ GOpenidaType *get_type_from_dex_pool(const GDexFormat *format, uint16_t index)
* *
******************************************************************************/
-GOpenidaType *get_class_from_dex_pool(const GDexFormat *format, uint16_t index)
+GOpenidaType *get_class_from_dex_pool(const GDexFormat *format, uint32_t index)
{
GOpenidaType *result; /* Instance à retourner */
off_t pos; /* Tête de lecture */
class_def_item class_def; /* Définition de la classe */
+ if (index >= format->header.class_defs_size)
+ return NULL;
+
pos = format->header.class_defs_off + index * sizeof(class_def_item);
if (!read_dex_class_def_item(format, &pos, &class_def))
@@ -180,6 +189,9 @@ GBinVariable *get_field_from_dex_pool(const GDexFormat *format, uint32_t index)
const char *name; /* Désignation humaine */
GOpenidaType *owner; /* Propriétaire du champ */
+ if (index >= format->header.field_ids_size)
+ return NULL;
+
pos = format->header.field_ids_off + index * sizeof(field_id_item);
if (!read_dex_field_id_item(format, &pos, &field_id))
@@ -231,7 +243,7 @@ GBinVariable *get_field_from_dex_pool(const GDexFormat *format, uint32_t index)
* *
******************************************************************************/
-GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uleb128_t index)
+GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uint32_t index)
{
GBinRoutine *result; /* Instance à retourner */
off_t pos; /* Tête de lecture */
@@ -243,6 +255,9 @@ GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uleb128_t index
string_id_item str_id; /* Identifiant de chaîne */
string_data_item str_data; /* Description de chaîne */
+ if (index >= format->header.method_ids_size)
+ return NULL;
+
pos = format->header.method_ids_off + index * sizeof(method_id_item);
if (!read_dex_method_id_item(format, &pos, &meth_id))