diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-10-16 23:16:25 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-10-16 23:16:25 (GMT) |
commit | 84581571e138d5b7984b6d3198296013ec157d30 (patch) | |
tree | e4308cab1f1bf85feaaeb91e33874b7ef7ccbcbb /src | |
parent | 6f9563a0184e36fab8d0c2c38d151827784e331e (diff) |
Fixed many bugs using valgrind.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@269 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/binaries/file.c | 5 | ||||
-rw-r--r-- | src/analysis/binary.c | 14 | ||||
-rw-r--r-- | src/arch/dalvik/processor.c | 2 | ||||
-rwxr-xr-x | src/format/dex/dex.c | 2 | ||||
-rw-r--r-- | src/format/format.c | 9 | ||||
-rw-r--r-- | src/gtkext/gtksourceview.c | 5 | ||||
-rw-r--r-- | src/plugins/plugin.c | 7 |
7 files changed, 25 insertions, 19 deletions
diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c index 0be1fd7..46307fb 100644 --- a/src/analysis/binaries/file.c +++ b/src/analysis/binaries/file.c @@ -162,7 +162,6 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) { GFileBinary *result; /* Adresse à retourner */ GLoadedBinary *loaded; /* Version parente */ - char *tmp; /* Nom de fichier modifiable */ result = g_object_new(G_TYPE_FILE_BINARY, NULL); loaded = G_LOADED_BINARY(result); @@ -171,10 +170,8 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) result->filename = strdup(filename); - tmp = strdup(filename); - loaded->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, tmp, + loaded->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, filename, &loaded->bin_data, &loaded->bin_length)); - free(tmp); if (loaded->format == NULL) { diff --git a/src/analysis/binary.c b/src/analysis/binary.c index fe8188b..d5bf029 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -733,7 +733,10 @@ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary, { GCodeBuffer *result; /* Tampon à retourner */ - if (index >= binary->decbuf_count) + if (binary->decbuf_count == 0) + result = NULL; + + else if (index >= binary->decbuf_count) result = binary->dec_buffers[binary->defsrc]; else @@ -792,11 +795,14 @@ void ack_completed_disassembly(void/*GDelayedDisassembly*/ *disass, GLoadedBinar files = g_binary_format_get_source_files(G_BIN_FORMAT(binary->format), &binary->decbuf_count, &binary->defsrc); - binary->dec_buffers = (GCodeBuffer **)calloc(binary->decbuf_count, sizeof(GCodeBuffer *)); + if (binary->decbuf_count > 0) + { + binary->dec_buffers = (GCodeBuffer **)calloc(binary->decbuf_count, sizeof(GCodeBuffer *)); - for (i = 0; i < binary->decbuf_count; i++) - binary->dec_buffers[i] = decompile_all_from_file(binary, files[i]); + for (i = 0; i < binary->decbuf_count; i++) + binary->dec_buffers[i] = decompile_all_from_file(binary, files[i]); + } diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index ef4b733..fbba5e2 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -427,6 +427,8 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc [DOP_SHR_INT_2ADDR] = dalvik_read_instr_shr_int_2addr, [DOP_USHR_INT_2ADDR] = dalvik_read_instr_ushr_int_2addr, [DOP_ADD_LONG_2ADDR] = dalvik_read_instr_add_long_2addr, + [DOP_SUB_LONG_2ADDR] = dalvik_read_instr_sub_long_2addr, + [DOP_MUL_LONG_2ADDR] = dalvik_read_instr_mul_long_2addr, [DOP_SHL_LONG_2ADDR] = dalvik_read_instr_shl_long_2addr, [DOP_SHR_LONG_2ADDR] = dalvik_read_instr_shr_long_2addr, diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c index 821da7a..b286f7c 100755 --- a/src/format/dex/dex.c +++ b/src/format/dex/dex.c @@ -255,6 +255,8 @@ static void g_dex_format_find_all_sources(GDexFormat *format) for (i = 0; i < format->classes_count; i++) { source = g_dex_class_get_source_file(format->classes[i], format); + if (source == NULL) continue; + found = false; for (k = 0; k < bf->src_count && !found; k++) diff --git a/src/format/format.c b/src/format/format.c index 4f6df03..f1ea4d4 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -503,6 +503,7 @@ bool init_all_formats(void) GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, off_t *length) { GBinFormat *result; /* Adresse à retourner */ + char *tmp; /* Nom de fichier modifiable */ GPluginModule **pglist; /* Liste de greffons */ size_t pgcount; /* Taille de cette liste */ size_t i; /* Boucle de parcours */ @@ -513,6 +514,8 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of + tmp = strdup(filename); + pglist = get_all_plugins_for_action(PGA_FORMAT_MATCHER, &pgcount); if (pgcount > 0) @@ -520,7 +523,7 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of lnf_rescan: for (i = 0; i < pgcount; i++) - switch (g_plugin_module_is_matching(pglist[i], &filename, content, length)) + switch (g_plugin_module_is_matching(pglist[i], &tmp, content, length)) { case MFA_MATCHED: /* FIXME */ @@ -539,6 +542,10 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of } + if (tmp == NULL) + free(tmp); + + for (i = 0; i < FID_COUNT && result == NULL; i++) diff --git a/src/gtkext/gtksourceview.c b/src/gtkext/gtksourceview.c index 5faed7b..4d8af09 100644 --- a/src/gtkext/gtksourceview.c +++ b/src/gtkext/gtksourceview.c @@ -151,9 +151,8 @@ static void gtk_source_view_attach_binary(GtkSourceView *view, GLoadedBinary *bi buffer = g_loaded_binary_get_decompiled_buffer(binary, -1); - /* FIXME */ + /* Si une source existe... */ if (buffer != NULL) - - gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer), addr, code); + gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer), addr, code); } diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 0cdcb04..89b46f0 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -357,13 +357,6 @@ MatchingFormatAction g_plugin_module_is_matching(const GPluginModule *plugin, ch result = plugin->is_matching(plugin, filename, data, length); - if (result == MFA_RELOAD) - { - if (old_filename != NULL) - free(old_filename); - free(old_data); - } - return result; } |