diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2010-05-20 22:10:04 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2010-05-20 22:10:04 (GMT) | 
| commit | 8cf0f3612c5fcb940b0a80ab6325a5c08e060430 (patch) | |
| tree | 523f22de616a490fc50065f2d5b152b936de1b52 /src/format | |
| parent | 44478b28bc5c4a8f9b064d0ae6936662e9ad11a9 (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')
| -rw-r--r-- | src/format/dex/pool.c | 19 | ||||
| -rw-r--r-- | src/format/dex/pool.h | 5 | 
2 files changed, 19 insertions, 5 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)) diff --git a/src/format/dex/pool.h b/src/format/dex/pool.h index 263a807..56fd99c 100644 --- a/src/format/dex/pool.h +++ b/src/format/dex/pool.h @@ -27,7 +27,6 @@  #include "dex.h"  #include "../../analysis/routine.h" -#include "../../common/leb128.h" @@ -39,7 +38,7 @@ GOpenidaType *get_type_from_dex_pool(const GDexFormat *, uint16_t);  /* Extrait une représentation de classe d'une table DEX. */ -GOpenidaType *get_class_from_dex_pool(const GDexFormat *, uint16_t); +GOpenidaType *get_class_from_dex_pool(const GDexFormat *, uint32_t); @@ -49,7 +48,7 @@ GOpenidaType *get_class_from_dex_pool(const GDexFormat *, uint16_t);  GBinVariable *get_field_from_dex_pool(const GDexFormat *, uint32_t);  /* Extrait une représentation de routine d'une table DEX. */ -GBinRoutine *get_routine_from_dex_pool(const GDexFormat *, uleb128_t); +GBinRoutine *get_routine_from_dex_pool(const GDexFormat *, uint32_t);  | 
