summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-24 17:42:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-24 17:42:12 (GMT)
commitf4c12b7fdc0482461f5c52161ea852c9d152cc4e (patch)
tree32f408f23ba528d2695adaeb8842915912a7ec4a
parentb758d4da4a8e15f84b0a43cb4f7f76f997fda6f7 (diff)
Cleaned the content of loaded binaries.
-rw-r--r--ChangeLog5
-rw-r--r--src/analysis/binary.c56
2 files changed, 31 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 58c468f..d80a44d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
18-01-24 Cyrille Bagard <nocbos@gmail.com>
+ * src/analysis/binary.c:
+ Clean the content of loaded binaries.
+
+18-01-24 Cyrille Bagard <nocbos@gmail.com>
+
* plugins/arm/v7/fetch.c:
* plugins/arm/v7/helpers.c:
* plugins/arm/v7/operands/coproc.c:
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 2769291..f38cf66 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -79,10 +79,7 @@ struct _GLoadedBinary
DBStorage storages[DBF_COUNT]; /* Lieux d'enregistrement */
GList *collections; /* Ensemble de modifications */
- GBinContent *content; /* Contenu binaire chargé */ //// REMME
-
GExeFormat *format; /* Format du binaire */
- GDbgFormat *debug; /* Informations de débogage */ //// REMME
GArchProcessor *proc; /* Architecture du binaire */
@@ -298,8 +295,6 @@ static void g_loaded_binary_interface_init(GLoadedContentInterface *iface)
static void g_loaded_binary_dispose(GLoadedBinary *binary)
{
- g_object_unref(G_OBJECT(binary->content));
-
if (binary->format != NULL)
g_object_unref(G_OBJECT(binary->format));
@@ -361,8 +356,6 @@ GLoadedBinary *g_loaded_binary_new(GBinContent *content)
log_variadic_message(LMT_PROCESS, _("Opening binary data from '%s'..."),
g_binary_content_describe(content, true));
- result->content = content;
-
/* Format d'exécutable */
status = find_matching_format(content, NULL, &target);
@@ -448,6 +441,7 @@ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const ch
GBinContent *content; /* Contenu à référencer */
xmlXPathObjectPtr xobject; /* Cible d'une recherche */
unsigned int i; /* Boucle de parcours */
+ bool attached; /* Bilan d'un chargement */
/* Contenus binaires associés */
@@ -462,27 +456,21 @@ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const ch
free(access);
if (hash == NULL)
- {
- free(content_path);
- return NULL;
- }
+ goto glbnfx_early_error;
content = g_study_project_find_binary_content_by_hash(project, hash);
+
free(hash);
if (content == NULL)
- {
- free(content_path);
- return NULL;
- }
+ goto glbnfx_early_error;
result = g_loaded_binary_new(content);
+ g_object_unref(G_OBJECT(content));
+
if (result == NULL)
- {
- free(content_path);
- return NULL;
- }
+ goto glbnfx_early_error;
asprintf(&access, "%s/DebugInfo", content_path);
@@ -499,25 +487,21 @@ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const ch
free(access);
if (hash == NULL)
- {
- free(content_path);
goto glbnfx_error;
- }
content = g_study_project_find_binary_content_by_hash(project, hash);
+
free(hash);
if (content == NULL)
- {
- free(content_path);
goto glbnfx_error;
- }
- if (!g_loaded_binary_attach_debug_info(result, content))
- {
- free(content_path);
+ attached = g_loaded_binary_attach_debug_info(result, content);
+
+ g_object_unref(G_OBJECT(content));
+
+ if (!attached)
goto glbnfx_error;
- }
}
@@ -529,14 +513,26 @@ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const ch
/* Elément divers associés au binaire */
if (!g_loaded_binary_load_storage(result, context, path))
- goto glbnfx_error;
+ goto glbnfx_final_error;
return result;
glbnfx_error:
+ free(content_path);
+
+ glbnfx_final_error:
+
+ g_object_unref(G_OBJECT(result));
+
+ return NULL;
+
+ glbnfx_early_error:
+
g_object_unref(G_OBJECT(result));
+ free(content_path);
+
return NULL;
}