summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-11-25 22:00:02 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-11-25 22:00:02 (GMT)
commit671cacb80fd438a5f4d51db853ed08d7a6edb9ab (patch)
tree3081bc41bca43137cca75e52fcbcf81798e8b4e2 /src
parent40d448bc4734882ca4a2580b481738f4720ebabe (diff)
Fortified Chrysalide a little bit against wrong APK files.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@291 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/links.c5
-rw-r--r--src/arch/dalvik/decomp/const.c1
-rw-r--r--src/arch/dalvik/operands/pool.c82
-rw-r--r--src/glibext/gbufferline.c10
-rw-r--r--src/glibext/gbufferline.h2
5 files changed, 84 insertions, 16 deletions
diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c
index 7cc3c27..0ba3fc6 100644
--- a/src/analysis/disass/links.c
+++ b/src/analysis/disass/links.c
@@ -122,6 +122,11 @@ void establish_links_between_lines(GArchInstruction *list, GBinRoutine **routine
iter = g_arch_instruction_find_by_address(list, start, true);
+ if (iter == NULL)
+ printf("no match for 0x%08llx\n", start);
+
+ if (iter != NULL)
+
for (iter = g_arch_instruction_get_next_iter(list, iter, end);
iter != NULL;
iter = g_arch_instruction_get_next_iter(list, iter, end))
diff --git a/src/arch/dalvik/decomp/const.c b/src/arch/dalvik/decomp/const.c
index 2e63b36..47a859e 100644
--- a/src/arch/dalvik/decomp/const.c
+++ b/src/arch/dalvik/decomp/const.c
@@ -95,6 +95,7 @@ GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GD
format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
value = get_string_from_dex_pool(format, index);
+ if (value == NULL) return NULL;
str = g_str_expression_new(value);
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c
index 803d173..fbe68cf 100644
--- a/src/arch/dalvik/operands/pool.c
+++ b/src/arch/dalvik/operands/pool.c
@@ -24,6 +24,7 @@
#include "pool.h"
+#include <stdio.h>
#include <string.h>
@@ -181,6 +182,7 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
{
const char *string; /* Chaîne de caractères #1 */
GDataType *type; /* Type à représenter */
+ size_t len; /* Taille du texte à créer */
char *tmp; /* Chaîne de caractères #2 */
GBinVariable *field; /* Champ à représenter */
GBinRoutine *routine; /* Routine à représenter */
@@ -188,14 +190,30 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
switch (operand->type)
{
case DPT_NONE:
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "????", 4, RTT_SECTION);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "????", 4, RTT_ERROR);
break;
case DPT_STRING:
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
string = get_string_from_dex_pool(operand->format, operand->index);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, string, strlen(string), RTT_STRING);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
+
+ if (string != NULL)
+ {
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, string, strlen(string), RTT_STRING);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
+ }
+ else
+ {
+ len = strlen(_("<bad string index (%d)>")) + 10 /* 4294967295U */ + 1;
+ tmp = calloc(len, sizeof(char));
+ snprintf(tmp, len, _("<bad string index (%d)>"), operand->index);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, len - 1, RTT_ERROR);
+
+ free(tmp);
+
+ }
+
break;
case DPT_TYPE:
@@ -205,14 +223,24 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
{
tmp = g_data_type_to_string(type);
g_object_unref(G_OBJECT(type));
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
+
}
else
- tmp = strdup(_("invalid type"));
+ {
+ len = strlen(_("<bad type index (%d)>")) + 10 /* 4294967295U */ + 1;
+ tmp = calloc(len, sizeof(char));
+ snprintf(tmp, len, _("<bad type index (%d)>"), operand->index);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, len - 1, RTT_ERROR);
+
+ }
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
free(tmp);
+
break;
case DPT_PROTO:
@@ -226,13 +254,24 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
{
tmp = g_binary_variable_to_string(field, false);
g_object_unref(G_OBJECT(field));
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
+
}
else
- tmp = strdup(_("invalid field"));
+ {
+ len = strlen(_("<bad field index (%d)>")) + 10 /* 4294967295U */ + 1;
+ tmp = calloc(len, sizeof(char));
+ snprintf(tmp, len, _("<bad field index (%d)>"), operand->index);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, len - 1, RTT_ERROR);
+
+ }
+
+ free(tmp);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
break;
case DPT_METHOD:
@@ -242,13 +281,24 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
{
tmp = g_binary_routine_to_string(routine);
g_object_unref(G_OBJECT(routine));
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
+
}
else
- tmp = strdup(_("invalid method"));
+ {
+ len = strlen(_("<bad method index (%d)>")) + 10 /* 4294967295U */ + 1;
+ tmp = calloc(len, sizeof(char));
+ snprintf(tmp, len, _("<bad method index (%d)>"), operand->index);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, len - 1, RTT_ERROR);
+
+ }
+
+ free(tmp);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
break;
}
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index c8ff5f2..cef34ef 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -458,6 +458,16 @@ static void g_buffer_line_class_init(GBufferLineClass *class)
attrib = pango_attr_foreground_new(0, 0, 0);
pango_attr_list_insert(class->attribs[RTT_KEY_WORD], attrib);
+ /* RTT_ERROR */
+
+ class->attribs[RTT_ERROR] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(65535, 0, 0);
+ pango_attr_list_insert(class->attribs[RTT_ERROR], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert(class->attribs[RTT_ERROR], attrib);
+
}
diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h
index 670df99..f1be296 100644
--- a/src/glibext/gbufferline.h
+++ b/src/glibext/gbufferline.h
@@ -93,6 +93,8 @@ typedef enum _RenderingTagType
RTT_KEY_WORD, /* Mot clef de langage */
+ RTT_ERROR, /* Erreur "interne" */
+
RTT_COUNT
} RenderingTagType;