summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog27
-rw-r--r--plugins/pychrysa/plugin.c9
-rw-r--r--src/analysis/binaries/file.c5
-rw-r--r--src/analysis/binary.c14
-rw-r--r--src/arch/dalvik/processor.c2
-rwxr-xr-xsrc/format/dex/dex.c2
-rw-r--r--src/format/format.c9
-rw-r--r--src/gtkext/gtksourceview.c5
-rw-r--r--src/plugins/plugin.c7
9 files changed, 61 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d3e7c6..b7572f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+12-10-17 Cyrille Bagard <nocbos@gmail.com>
+
+ * plugins/pychrysa/plugin.c:
+ The one which reallocs has to become the one which frees !
+
+ * src/analysis/binaries/file.c:
+ See plugins/pychrysa/plugin.c.
+
+ * src/analysis/binary.c:
+ Handle the case where no source is found.
+
+ * src/arch/dalvik/processor.c:
+ Add missing disassembling call references for DOP_SUB_LONG_2ADDR
+ and DOP_MUL_LONG_2ADDR.
+
+ * src/format/dex/dex.c:
+ Handle the case where no source is found.
+
+ * src/format/format.c:
+ See plugins/pychrysa/plugin.c.
+
+ * src/gtkext/gtksourceview.c:
+ Formally handle the case where no source is found.
+
+ * src/plugins/plugin.c:
+ See plugins/pychrysa/plugin.c.
+
12-10-16 Cyrille Bagard <nocbos@gmail.com>
* src/analysis/disass/output.c:
diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c
index 70ca26e..9601432 100644
--- a/plugins/pychrysa/plugin.c
+++ b/plugins/pychrysa/plugin.c
@@ -440,13 +440,20 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *plu
if (result != MFA_NONE && new_data == Py_None) goto is_matching_bad;
if (new_filename != Py_None)
+ {
+ free(*filename);
*filename = strdup(PyString_AsString(new_filename));
+ }
+
/**
* La suppression de la part du greffon n'est permise que
* si une prise en charge est assurée.
*/
else if (result != MFA_NONE)
+ {
+ free(*filename);
*filename = NULL;
+ }
/**
* Pareil que précédemment.
@@ -456,6 +463,8 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *plu
tmp = PyByteArray_AsString(new_data);
*length = PyByteArray_Size(new_data);
+ free(*data);
+
*data = (bin_t *)calloc(*length, sizeof(bin_t));
memcpy(*data, tmp, *length * sizeof(bin_t));
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;
}