summaryrefslogtreecommitdiff
path: root/plugins/elf
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 /plugins/elf
parent304445ae3f7a159be55fa91b95428251ef8a362e (diff)
Cleaned some format loading processes.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/format.c47
1 files changed, 16 insertions, 31 deletions
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;