summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-04-27 09:53:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-04-27 09:53:32 (GMT)
commitce422fd3b2831ab37de599f40297c6781e5bdfc0 (patch)
treebb58c10a11ec3c7f7d7e876659d187c9097ccb70 /plugins
parent2bdc454c947411bf654838e1b2a25c3203d2bc72 (diff)
Fixed a size overflow in the global register list.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dalvik/register.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/dalvik/register.c b/plugins/dalvik/register.c
index 0833650..8374e75 100644
--- a/plugins/dalvik/register.c
+++ b/plugins/dalvik/register.c
@@ -85,7 +85,7 @@ GDalvikRegister *_g_dalvik_register_new(uint16_t);
/* Conservation des registres utilisés */
static GDalvikRegister **_dalvik_registers = NULL;
-static uint16_t _dreg_count = 0;
+static size_t _dreg_count = 0;
G_LOCK_DEFINE_STATIC(_dreg_mutex);
@@ -361,18 +361,21 @@ int g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b
static GDalvikRegister *get_dalvik_register(uint16_t index)
{
GDalvikRegister *result; /* Structure à retourner */
- uint16_t i; /* Boucle de parcours */
+ size_t new_count; /* Nouvelle taille à considérer*/
+ size_t i; /* Boucle de parcours */
G_LOCK(_dreg_mutex);
if (index >= _dreg_count)
{
- _dalvik_registers = realloc(_dalvik_registers, (index + 1) * sizeof(GDalvikRegister *));
+ new_count = index + 1;
- for (i = _dreg_count; i < (index + 1); i++)
+ _dalvik_registers = realloc(_dalvik_registers, new_count * sizeof(GDalvikRegister *));
+
+ for (i = _dreg_count; i < new_count; i++)
_dalvik_registers[i] = NULL;
- _dreg_count = index + 1;
+ _dreg_count = new_count;
}
@@ -404,7 +407,7 @@ static GDalvikRegister *get_dalvik_register(uint16_t index)
void clean_dalvik_register_cache(void)
{
- uint16_t i; /* Boucle de parcours */
+ size_t i; /* Boucle de parcours */
G_LOCK(_dreg_mutex);