summaryrefslogtreecommitdiff
path: root/src/format/dex/pool.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-05-20 22:10:04 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-05-20 22:10:04 (GMT)
commit8cf0f3612c5fcb940b0a80ab6325a5c08e060430 (patch)
tree523f22de616a490fc50065f2d5b152b936de1b52 /src/format/dex/pool.c
parent44478b28bc5c4a8f9b064d0ae6936662e9ad11a9 (diff)
Increased security by checking the requested index when reading a pool item.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@162 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
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))