summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-26 21:39:34 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-26 21:39:34 (GMT)
commit8a7d7b3303dee1a381893391c04acab35dec6942 (patch)
treedca8ae17ad327c215f58e40f0a200488c651afcf
parent304445ae3f7a159be55fa91b95428251ef8a362e (diff)
Cleaned some format loading processes.
-rw-r--r--ChangeLog6
-rw-r--r--plugins/elf/format.c47
-rw-r--r--plugins/mobicore/mclf.c19
3 files changed, 29 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index ced1ad5..2ec6dab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+18-01-26 Cyrille Bagard <nocbos@gmail.com>
+
+ * plugins/elf/format.c:
+ * plugins/mobicore/mclf.c:
+ Clean some format loading processes.
+
18-01-24 Cyrille Bagard <nocbos@gmail.com>
* plugins/pychrysalide/arch/vmpa.c:
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
index a5c8c92..9e3b636 100644
--- a/plugins/elf/format.c
+++ b/plugins/elf/format.c
@@ -255,44 +255,37 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus
g_binary_format_set_content(base, content);
if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))
- {
- /* TODO */
- return NULL;
- }
-
+ goto gefn_error;
/* Vérification des tailles d'entrée de table */
if (ELF_HDR(result, result->header, e_phentsize) != ELF_SIZEOF_PHDR(result))
{
- log_variadic_message(LMT_BAD_BINARY, _("Corrupted program header size (%hu); fixed! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
+ log_variadic_message(LMT_BAD_BINARY,
+ _("Corrupted program header size (%hu); fixed!" \
+ " -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
ELF_HDR(result, result->header, e_phentsize),
ELF_HDR(result, result->header, e_phentsize),
- ELF_SIZEOF_PHDR(result), ELF_HDR_OFFSET_OF(result, e_phentsize));
+ ELF_SIZEOF_PHDR(result),
+ ELF_HDR_OFFSET_OF(result, e_phentsize));
+
ELF_HDR_SET(result, result->header, e_phentsize, ELF_SIZEOF_PHDR(result));
+
}
if (ELF_HDR(result, result->header, e_shentsize) != ELF_SIZEOF_SHDR(result))
{
- log_variadic_message(LMT_BAD_BINARY, _("Corrupted section header size (%hu); fixed! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
+ log_variadic_message(LMT_BAD_BINARY,
+ _("Corrupted section header size (%hu); fixed!" \
+ " -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
ELF_HDR(result, result->header, e_shentsize),
ELF_HDR(result, result->header, e_shentsize),
- ELF_SIZEOF_SHDR(result), ELF_HDR_OFFSET_OF(result, e_shentsize));
+ ELF_SIZEOF_SHDR(result),
+ ELF_HDR_OFFSET_OF(result, e_shentsize));
+
ELF_HDR_SET(result, result->header, e_shentsize, ELF_SIZEOF_SHDR(result));
- }
- /* FIXME : à améliorer */
- /*
- if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length)
- {
- log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
- ELF_HDR(result, result->header, e_shnum),
- 0, ELF_HDR_OFFSET_OF(result, e_shnum));
- ELF_HDR_SET(result, result->header, e_shnum, 0);
}
- */
-
-
/**
* On inscrit les éléments préchargés avant tout !
@@ -307,18 +300,10 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus
if (!load_elf_symbols(result, status))
- {
- /* TODO */
- return NULL;
- }
-
+ goto gefn_error;
if (!find_all_elf_strings(result))
- {
- /* TODO */
- return NULL;
- }
-
+ goto gefn_error;
if (!g_executable_format_complete_loading(exe_format, status))
goto gefn_error;
diff --git a/plugins/mobicore/mclf.c b/plugins/mobicore/mclf.c
index 7697d15..653ffaa 100644
--- a/plugins/mobicore/mclf.c
+++ b/plugins/mobicore/mclf.c
@@ -210,24 +210,19 @@ GBinFormat *g_mclf_format_new(GBinContent *content, GExeFormat *parent, GtkStatu
g_binary_format_set_content(G_BIN_FORMAT(result), content);
-
-
if (!read_mclf_header(result, &result->header, result->endian))
- {
- /* TODO */
- return NULL;
- }
+ goto gmfn_error;
+ if (!load_mclf_symbols(result))
+ goto gmfn_error;
+ return G_BIN_FORMAT(result);
- if (!load_mclf_symbols(result))
- {
- /* TODO */
- return NULL;
- }
+ gmfn_error:
+ g_object_unref(G_OBJECT(result));
- return G_BIN_FORMAT(result);
+ return NULL;
}